My input A is C×H×W. And I want to use torch.nn.Upsample to resize it.
I know the format should be Batch×C×H×W ,so I do:
self.upsample = torch.nn.Upsample(size=[128,128], mode=‘bilinear’)
A = torch.unsqueeze(A, 0) (to get 1×C×H×W)
A = self.upsample(A)
However, it reports:
raise NotImplementedError(“Got 3D input, but bilinear mode needs 4D input”)
NotImplementedError: Got 3D input, but bilinear mode needs 4D input
What is wrong with my code?Can someone help me? Thanks!