How to resize all 4 dimensions (NCHW) in PyTorch with F.interpolate?
I've been trying to figure out how to resize the Batch, Channels, Height, and Width dimensions in a tensor. Currently I am able to resize the Channels, Height, and Width dimensions, but the Batch dimension remains the same.
x = torch.ones(3,4,64,64)

x = F.interpolate(x.unsqueeze(0), size=(3,4,4), mode=&quot;trilinear&quot;).squeeze(0)

x.size() # (3,3,4,4) # batch dimension has not been resized.
# I need x to be resized so that it has a size of: (1,3,4,4)


# Is this a good idea?
x = x.permute(1,0,2,3)
x = F.interpolate(x.unsqueeze(0), size=(1, x.size(2), x.size(3)), mode=&quot;trilinear&quot;).squeeze(0)
x = x.permute(1,0,2,3)

x.size() # (1,3,4,4)

Should I permute the tensor to resize the batch dimension? Or iterate through it in some way?

This seems to let me resize the batch dimension:
x = x.permute(1,0,2,3)
x = F.interpolate(x.unsqueeze(0), size=(1, x.size(2), x.size(3)), mode=&quot;trilinear&quot;).squeeze(0)
x = x.permute(1,0,2,3)

