Python pytorch正向方法中的类型不匹配

Python pytorch正向方法中的类型不匹配,python,numpy,pytorch,Python,Numpy,Pytorch,我试图通过加载自己的数据来扩充找到的MNIST。 为此,我使用numpy数组training\u x,training\u y,我将其转换如下: training_X = torch.from_numpy(training_X) training_y = torch.from_numpy(training_y) [请注意,原始的training_y是scikit learn的LabelEncoder的输出] 并通过执行以下操作添加到数据加载器: torch.utils.data.Tensor

我试图通过加载自己的数据来扩充找到的MNIST。 为此,我使用numpy数组
training\u x
training\u y
,我将其转换如下:

training_X = torch.from_numpy(training_X)
training_y = torch.from_numpy(training_y) 
[请注意,原始的
training_y
是scikit learn的LabelEncoder的输出]

并通过执行以下操作添加到数据加载器:

torch.utils.data.TensorDataset(training_X, training_y)
培训时,我收到以下错误:

TypeError: addmm_ received an invalid combination of arguments - got (int, int, torch.cuda.FloatTensor, torch.FloatTensor), but expected one of:
* (torch.cuda.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (torch.cuda.sparse.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (float beta, torch.cuda.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (float alpha, torch.cuda.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (float beta, torch.cuda.sparse.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (float alpha, torch.cuda.sparse.FloatTensor mat1, torch.cuda.FloatTensor mat2)
* (float beta, float alpha, torch.cuda.FloatTensor mat1, torch.cuda.FloatTensor mat2)
  didn't match because some of the arguments have invalid types: (int, int, torch.cuda.FloatTensor, !torch.FloatTensor!)
v * (float beta, float alpha, torch.cuda.sparse.FloatTensor mat1, torch.cuda.FloatTensor mat2)
  didn't match because some of the arguments have invalid types: (int, int, !torch.cuda.FloatTensor!, !torch.FloatTensor!)
我曾尝试将输入张量更改为浮动、双精度和长精度,但似乎我仍然缺少一些关键的东西


如何让模型接受我的输入?

您提供的第四个参数似乎是
torch.FloatTensor
,但它应该是
torch.cuda.FloatTensor

您是否尝试调用该参数的
.cuda()


请参见

您提供的第四个参数似乎是
torch.FloatTensor
,但它应该是
torch.cuda.FloatTensor

您是否尝试调用该参数的
.cuda()