visual-qa
visual-qa copied to clipboard
trainLSTM_1.py unreshapeable error
The environment has been tested by running get_started.sh
, however, when run python trainLSTM_1.py
something goes wrong, saying :
Training started...
Traceback (most recent call last):
File "trainLSTM_1.py", line 126, in
it says something wrong with the reshape...can anyone help me?
I also got this error log...have you fixed it?
I think I got what's going on.
line 66 in trainLSTM_1.py
language_model.add(LSTM(output_dim = args.num_hidden_units_lstm, return_sequences=False, input_shape=(max_len, word_vec_dim)))
the LSTM was defined with input shape being max_len with the value 30 meaning the time steps of LSTM being fixed to 30, keep this in mind.
line 112:
X_q_batch = get_questions_tensor_timeseries(qu_batch, nlp, timesteps)
this time the timesteps
is a varying number as the different batch may have varying length, which does not match the input shape of the LSTM thus causing the unreshapeable error.
If you want to know it thoroughly, check the definition of get_questions_tensor_timeseries
in features.py
I think you'll get what I mean.
Correct me if I'm wrong!
Has a mechanism to fix this been found?
Based on @NateLol 's description, I modified line 108 to set timestamps equal to 30. Training appears to be working now.
Hey @aniemerg,
Came back to this code reading after a long period of time, I might have another better solution! Change language_model
definition, the parameters of LSTM()
to be LSTM(output_dim = args.num_hidden_units_lstm, return_sequences=False, input_dim=word_vec_dim)
instead of compiling the model with fixed timesteps, just specify it's input_dim
rather than input_shape
.
Thus varying lengths of sequence can be processed! However, the training error seems not decreasing over time, Any thoughts on that?