当前位置:  开发笔记 > 人工智能 > 正文

How to resize a PyTorch tensor?

如何解决《HowtoresizeaPyTorchtensor?》经验,为你挑选了1个好方法。

Now I have a torch.Tensor of size (5, 1, 44, 44) in Pytorch.

5 = batch size

1 = channel

44= image height

44= image width

and I want to 'resize' it to shape (5, 1, 224, 224)

How can I do that? What functions should I use?



1> Shai..:

It seems like you are looking for interpolate (a function in nn.functional):

import torch.nn.functional as nnf

x = torch.rand(5, 1, 44, 44)
out = nnf.interpolate(x, size=(224, 224), mode='bicubic', align_corners=False)

推荐阅读
携手相约幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有