Torch调整张量大小。

如何在 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]

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

点赞
用户117844
用户117844

你需要做的是:

images:resize(...)

你实际做的是:

images.resize(...)

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

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

2015-04-03 16:32:40