2015-04-03 87 views
7

如何調整火炬張量?記錄在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] 

爲什麼這種方法不起作用?

回答

9

你需要做的:

images:resize(...) 

你做了什麼:

images.resize(...) 

images.resize沒有通過電流張量作爲第一個參數。

images:resize(...)相當於images.resize(images, ...)