only batches of spatial targets supported (3D tensors) but got targets of dimension
问题产生的原因是使用nn.CrossEntropyLoss()来计算损失的时候,target的维度超过4importtorchimporttorch.nnasnnlogit=torch.ones(size=(4,32,256,256))#b,c,h,wtarget=torch.ones(size=(4,1,256,256))criterion=nn.CrossEntropyLoss()loss=c