[torch] some bugs

来源:互联网 发布:什么是数据挖掘技术 编辑:程序博客网 时间:2024/06/04 19:25

error1

1.”bad argument #1 to ‘set’ (expecting number or torch.DoubleTensor or torch.DoubleStorage at /tmp/luarocks_torch-scm-1-9965/torch7/generic/Tensor.c:1153)”

mulLSTMmodel = nn.MapTable(nn.convLSTM(opt))out = mulLSTMmodel:forward(input)

I wrote that nn.convLSTM, then error happens at the 2rd line.
I checked the MapTable.lua, then I found (default) it will copy self.sharedparams = {'weight', 'bias', 'gradWeight', 'gradBias'},
so I

mulLSTMmodel = nn.MapTable(nn.convLSTM(opt), false)

However, it may influence the backward.
Finally, I decided to write my own MapTable.

error2

“inputs[1] should be an nngraph.Node but is of type torch.DoubleTensor”
don’t use any nnfunction in a layer written by yourself if you require ‘nngraph’

require 'nn'local layer, Parent = torch.class('nn.mul_convLSTM', 'nn.Module')...function layer:updateOutput(input)    ...    out = nn.Reshape(out2)end

the code shown above works well, however, once you use require nngraph in the code,
–> “inputs[1] should be an nngraph.Node but is of type torch.DoubleTensor”