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?
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, ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With