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]

为什么这种方法不起作用?

4

1 回答 1

9

你需要做:

images:resize(...)

你做了什么:

images.resize(...)

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

images:resize(...)相当于images.resize(images, ...)

于 2015-04-03T16:32:40.753 回答