torch / nn

Other
1.34k stars 967 forks source link

ParallelCriterion input form? #1302

Closed jmfu95 closed 6 years ago

jmfu95 commented 6 years ago

I use : local nll = nn.ClassNLLCriterion() local kl = nn.DistKLDivCriterion() local criterion = nn.ParallelCriterion():add(nll,0.5):add(kl)

and input: {1 : DoubleTensor - size: 50x24 2 : DoubleTensor - size: 50x24}

but i get the following error: torch/install/share/lua/5.1/nn/LookupTable.lua:59: attempt to call method 'isContiguous' (a nil value) stack traceback: ...shedongyu/torch/install/share/lua/5.1/nn/LookupTable.lua:59: in function 'makeInputContiguous' ...shedongyu/torch/install/share/lua/5.1/nn/LookupTable.lua:72: in function 'func' ...hedongyu/torch/install/share/lua/5.1/nngraph/gmodule.lua:345: in function 'neteval' ...hedongyu/torch/install/share/lua/5.1/nngraph/gmodule.lua:380: in function 'forward' ./trainer.lua:76: in function 'opfunc' ...shedongyu/torch/install/share/lua/5.1/optim/adadelta.lua:31: in function 'optim_method' ./trainer.lua:102: in function 'train' main.lua:206: in function 'train_loop' main.lua:393: in function 'main' main.lua:406: in main chunk [C]: in function 'dofile' ...ngyu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00406670 so i want to know the input form is wrong?

tastyminerals commented 6 years ago

The error means that your input tensor is nil (does not have isContiguous method). Check what you feed into your model.

jmfu95 commented 6 years ago

Thanks for replying! It may require input as ParallelTable, so i change the input. But the mistake still exists. So do you know how i should change the input to feed into model?

tastyminerals commented 6 years ago

There is nothing wrong with your parallel container architecture. The error you're are getting means that one of your input DoubleTensors is nil, you are not reading anything from your training data.

jmfu95 commented 6 years ago

Thank you! I have fixed this problem.