Element-Research / rnn

Recurrent Neural Network library for Torch7's nn
BSD 3-Clause "New" or "Revised" License
941 stars 313 forks source link

Nested Sequencers error #329

Open gnageeb opened 8 years ago

gnageeb commented 8 years ago

I need to build a model with two nested sequencers cause I have my data in the form of sequences of sequences.

morph_lt1 = nn.LookupTableMaskZero(vocab_size1,emb_size)

local word_mod_add = nn.Sequential()
word_mod_add:add(morph_lt1)
word_mod_add:add(nn.SplitTable(2))
lstm_inner = nn.LSTM(emb_size,emb_size)
word_mod_add:add(nn.Sequencer(lstm_inner)) -- this model outputs the word embeddings
word_mod_add:add(nn.SelectTable(-1))
word_mod_add:add(nn.Tanh())

word_mod_add = nn.Recursor(word_mod_add)
model_l1 = nn.Sequential()
model_l1:add(nn.SplitTable(2))
model_l1:add(nn.Sequencer(word_mod_add))
lstm_outer = nn.LSTM(emb_size,emb_size)
model_l1:add(nn.Sequencer(lstm_outer))
model_l1:add(nn.SelectTable(-1))
model_l1:add(nn.Tanh())

model_l1:cuda()

the input is a tensor with the dimensions batch_size * outer_seq_len * inner_seq_len The model above works just fine in the forward pass, however in the backward pass it throws the following exception: In 2 module of nn.Sequential: ...ad/torch/install/share/lua/5.1/rnn/AbstractRecurrent.lua:200: no output for step 59 59 is the outer_seq_len. I checked the outputs of the module mentioned in the exception and there actually is an output for this step. Would anyone please advice?

juesato commented 8 years ago

Have you tried printing self.output inside the source for AbstractRecurrent? I'd be very surprised if there was anything inside there.

What did you do to check the output exists? If it's really there, then stepping forwards with a debugger to see when it becomes nil should probably work

amdcat commented 7 years ago

I got the same problem. any advice now?

murthyrudra commented 7 years ago

Hi, I am getting the same problem. Any advice on where i am going wrong?

gnageeb commented 7 years ago

@juesato That was the first thing to come to my mind back then. The output values are actually there and it never become nil surprisingly! Sorry for the late reply. I'm doing order aware language modelling on sentence level, that's why it would be useful to make it work. Thank you!