RuntimeError: multi-target not supported at C:/w/b/windows/pytorch/aten/src\THCUNN/generic/ClassNLLC

错误:RuntimeError: multi-target not supported at C:/w/b/windows/pytorch/aten/src\THCUNN/generic/ClassNLLCriterion.cu:15
在使用交叉熵损失函数的时候,label应该只有batchsize这一个维度的。
如果label是【batchszie,1】就会出现上述的错误。应该用squeeze()函数降低纬度
label=label.squeeze()

你可能感兴趣的:(深度学习,pytorch,python)