[英]Resize RGB Tensor pytorch
I want to resize a 3-D RBG tensor in pytorch.我想在 pytorch 中调整 3-D RBG 张量的大小。 I know how to resize a 4-D tensor, but unfortunalty this method does not work for 3-D.
我知道如何调整 4-D 张量的大小,但不幸的是,这种方法不适用于 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.如果我有一个 4-D 矢量它工作正常。
#input shape: [2, 3, 100, 200]
out = torch.nn.functional.interpolate(T,size=(100,80), mode='bilinear')
Any suggestions?有什么建议? Thanks in advance!
提前致谢!
Thanks to jodag I found the answer:感谢 jodag 我找到了答案:
# 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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.