Reputation: 5698
How do I resize a Tensor in Torch? Methods documented in https://github.com/torch/torch7/blob/master/doc/tensor.md#resizing do not seem to work.
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]
Why doesn't this approach work?
Upvotes: 7
Views: 6324
Reputation: 2266
You need to do:
images:resize(...)
What you did:
images.resize(...)
images.resize does not pass the current tensor as the first argument.
images:resize(...)
is equivalent to images.resize(images, ...)
Upvotes: 9