成功解决RuntimeError: multi-target not supported at /pytorch/aten/src/THCUNN/generic/

计算交叉熵时报错:
RuntimeError: multi-target not supported at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:15

维度不匹配导致
input, target的维度与F.cross_entropy()函数要求的维度不匹配

解决方法:

F.cross_entropy( input, target.squeeze() )

你可能感兴趣的:(bug,pytorch)