我正在尝试通过加载我自己的数据来扩充发现here的MNIST。
为此,我有numpy数组training_x
,training_y
,我将其变换如下:
training_X = torch.from_numpy(training_X)
training_y = torch.from_numpy(training_y)
[请注意原始training_y
是scikit-learn的LabelEncoder输出]
并通过执行以下操作添加到DataLoader:
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!)
我尝试将输入张量更改为float,double和long但似乎我仍然缺少一些关键的东西。
如何让模型接受我的输入?
答案 0 :(得分:0)
您提供的第四个参数似乎是torch.FloatTensor
但它应该是torch.cuda.FloatTensor
。
您是否尝试在该论点上调用.cuda()
?