viorik / ConvLSTM

Spatio-temporal video autoencoder with convolutional LSTMs
291 stars 85 forks source link

Tensor and array of tensors cannot be both used in nn.SequencerCriterion(...):updateOutput() #13

Closed evgen48 closed 8 years ago

evgen48 commented 8 years ago

Hi @viorik I'm trying to apply trained model, and got folowing errors.

user@lin01:~/LSTM/ConvLSTM$ qlua main-demo-ConvLSTM.lua
Loading model from fileoutputs_mnist_line/model_3000.bin
Training done
Start quantitative evaluation
main: Loaded 2000 test sequences
qlua: bad argument #2 to '?' (out of range)
stack traceback:
    [C]: at 0x7f53878e79c0
    [C]: at 0x7f534116a2d0
    [C]: in function '__index'
    ...r/torch/install/share/lua/5.1/rnn/SequencerCriterion.lua:42: in function 'updateOutput'
    main-demo-ConvLSTM.lua:161: in function 'main'
    main-demo-ConvLSTM.lua:177: in main chunk

I narrowed down, that in evaluation phase you are loading 19 images from database to inputTable

for i = 1,data:size(1)-1 do
      table.insert(inputTable, data[i]:cuda())
    end

And one remained image to targetTensor target:resizeAs(data[1]):copy(data[data:size(1)])

That is different from what is done in learning phase, and thus criterion:update output, that would like to iterate overtables, noticed that second arg is not a vector it report off-by-one error. I dont have enough expertise currently to suggest a fix, thus i would like to hear from you. I think idea was to get an error score by loading 19 pictures to a model , and then do a prediction, and compare to 20th one, however cannot fix it myself.

I have modified sources, so line numbers are not correct, the problem is here torch/install/share/lua/5.1/rnn/SequencerCriterion.lua: SequencerCriterion:updateOutput self.output = self.output + criterion:forward(input, targetTable[i]) Where target table has size=1

Please help.

viorik commented 8 years ago

Hi @evgen48 Apologies for that, there was a bug in the evaluation code. I've corrected it now, so please check the update, and let me know if this runs fine. cheers.

evgen48 commented 8 years ago

Thanks @viorik , now it works. Ideally i would also move opt.train = true into opts-mnist.lua file, i can provide pull request for that kind of refactoring

viorik commented 8 years ago

That is a minor detail, it actually used to be in opts-mnist file, but I moved it in main for commodity. Glad that the issue is solved.