-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi,
I post previously about issue( input and gradOutput shapes do not match), and you recommended me install specific torch with Cuda 5 or 6. I did it, but it didn't workout unfortunately. Then i try your second recommendation to reshape the data in spatial pleases and i try as below:(trainer.lua)
-- evaluate function for complete mini batch
for i = 1,#inputs do
-- estimate f
local output = model:forward(inputs[i])
model:add(nn.Reshape(inputs[i])) -- here
--clip extra output from shift and stitch
-- output = tablex.map(function(t) return t[{{1,targets[i][1]:size(1)},{1,t:size(2)}}] end, output)
-- print(inputs[i])
-- print(output)
output = output[{ {1, targets[i]:size(1)},{} }]
-- print(targets[i])
local err
if cuda then
err = criterion:forward(output:cuda(), targets[i]:cuda())
model:add(nn.Reshape(targets[i])) -- here
else
err = criterion:forward(output, targets[i])
model:add(nn.Reshape(targets[i])) -- here
end
f = f + err
-- estimate df/dW
this time it gave me this error:
/torch/install/bin/luajit: bad argument #3 to '?' (number expected, got userdata)
stack traceback:
[C]: at 0x7fa0ce476830
[C]: in function '__newindex'
/home/shayan/torch/install/share/lua/5.1/nn/Reshape.lua:19: in function '__init'
/home/shayan/torch/install/share/lua/5.1/torch/init.lua:91: in function </home/shayan/torch/install/share/lua/5.1/torch/init.lua:87>
[C]: in function 'Reshape'
./Trainer.lua:71: in function 'opfunc'
/home/shayan/torch/install/share/lua/5.1/optim/sgd.lua:44: in function 'optimMethod'
./Trainer.lua:111: in function 'train'
main.lua:93: in function 'main'
main.lua:126: in main chunk
[C]: in function 'dofile'
...ayan/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50
Asking for input shape numbers. I don't know the input shape number. Moreover, I read the code, and I didn't get where is the input shape. The only thing I am sure of is the input always greater than the gradOutput by one or tow numbers as you can see from errors below :
5.1/nn/THNN.lua:110: input and gradOutput shapes do not match: input [524 x 2], gradOutput [522 x 2]
5.1/nn/THNN.lua:110: input and gradOutput shapes do not match: input [162 x 2], gradOutput [161 x 2]
5.1/nn/THNN.lua:110: input and gradOutput shapes do not match: input [566 x 2], gradOutput [564 x 2]
5.1/nn/THNN.lua:110: input and gradOutput shapes do not match: input [254 x 2], gradOutput [253 x 2]
But no specific number
Can you help me to solve this problem. I am trying to find other solution but I am new to torch and lua (To be onset I am learning them just for your code ). I am studying a lot of tutorials but i didn't get all your code yet.
Thanks in advance.