pytorch报错
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target'
原因 使用了loss = criterion(output,target)
loss = criterion(output,target)
# 而output 和 target的类型都是
'torch.cuda.FloatTensor'
'torch.cuda.FloatTensor'
output.shape :
torch.Size([64, 10])
target.shape :
torch.Size([64, 1, 28, 28])
解决办法
target1 = torch.LongTensor(target)
loss = criterion(output,target1)