appleUserK
appleUserK

Reputation: 73

Resize RGB Tensor pytorch

I want to resize a 3-D RBG tensor in pytorch. I know how to resize a 4-D tensor, but unfortunalty this method does not work for 3-D.

The input is:

#input shape: [3, 100, 200]   ---> desired output shape: [3, 80, 120]

if I have a 4-D vector it works fine.

#input shape: [2, 3, 100, 200]
out = torch.nn.functional.interpolate(T,size=(100,80), mode='bilinear')

Any suggestions? Thanks in advance!

Upvotes: 3

Views: 2826

Answers (1)

appleUserK
appleUserK

Reputation: 73

Thanks to jodag I found the answer:

# input shape [3, 200, 120]
T = T.unsqueeze(0)
T = torch.nn.functional.interpolate(T,size=(100,80), mode='bilinear')
T = T.squeeze(0)
# output shape [3, 100, 80]

Upvotes: 3

Related Questions