1、dimension out of range (expected to be in range of [-1, 0], but got 1)
参考https://github.com/pytorch/pytorch/issues/5554
二分类问题,target.size [batch_size,]
修改,output_class.size() 为[batch_size,2]
2、RuntimeError: multi-target not supported at ...
target.size =[batch_size,1]出错
参考:https://blog.csdn.net/ccbrid/article/details/79844005
https://blog.csdn.net/york1996/article/details/81875508
修改,target=target.squeeze()
3、element 0 of tensors does not require grad and does not have a grad_fn
参考:https://blog.csdn.net/jacke121/article/details/82733197
element 0 of tensors does not require grad and does not have a grad_fn
这个是因为requires_grad=False,应该为true
x = Variable(torch.ones(2,2),requires_grad=False)
4、CrossEntropyLoss(output,target)
output type : torch.FloatTorch
target type : torch.LongTorch
output_class = Variable(output_class.type(torch.FloatTensor)
label = Variable(label.type(torch.LongTensor))