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()

猜你喜欢

转载自blog.csdn.net/weixin_61745097/article/details/130567917