pretrained-models.pytorch icon indicating copy to clipboard operation
pretrained-models.pytorch copied to clipboard

problem:RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [20]

Open fenglv12345 opened this issue 5 years ago • 2 comments

(1)when i run the architecture squeezenet1_0 and squeezenet1_1 ,I met the problem above. (2)then I print the shape of output and target as below: output.shape torch.Size([20, 1000, 1, 1]) target.shape torch.Size([20]) obviously, it' s the reason that the shape is not matched. (3)so i add the code: output = model(input) output =output.reshape(-1,1000) and it worked (4)but there maybe remains some better solution,such as modify the code of squeezenet1_0 and squeezenet1_1(ps: because other architetures don't have the problems above)

fenglv12345 avatar Apr 19 '19 08:04 fenglv12345

I had the same problem:Runtimeerror:lonely batches of spatial targets supported (non-empty 3D tensors)but got targets of size[2,513,513,3],How did you modify it

kungkook avatar Apr 09 '20 11:04 kungkook

same problem, but obviously the issue should be on PyTorch, not this repo.

s-mostafa-a avatar Jul 06 '20 22:07 s-mostafa-a