Torch调整张量大小

7

我该如何在Torch中调整张量的大小?在https://github.com/torch/torch7/blob/master/doc/tensor.md#resizing中记录的方法似乎无法正常工作。

images = image.load('image.png',1,'float')
print(images:size()) 
-- result: 224x224 [torch.LongStorage of size 2] 

images.resize(torch.FloatTensor(224,224,1,1))
print(images:size()) 
-- result: 224x224 [torch.LongStorage of size 2] 
-- expected: 224x224x1x1 [torch.LongStorage of size 4]

为什么这种方法行不通?
1个回答

9

您需要做:

images:resize(...)

您需要做的事情:

images.resize(...)

images.resize不会将当前张量作为第一个参数传递。

images:resize(...) 等同于 images.resize(images, ...)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接