I am trying to perform concatenation on the Bidirectinal LSTM layer. I have my model defined like this:


LSTM_word_1 = Bidirectional(LSTM(80, activation='tanh', dropout_W = 0.25, dropout_U = 0.25,return_sequences=True))
model1 = Input(shape=(trainDataVecs.shape[1],),dtype='int32')
lstm_word_out_1 = LSTM_word_1(embedded_sequences1)

LSTM_word_2 = Bidirectional(LSTM(80, activation='tanh', dropout_W = 0.25, dropout_U = 0.25,return_sequences=True))
model2 = Input(shape=(trainDataVecs.shape[1],),dtype='int32')
lstm_word_out_2 = LSTM_word_2(embedded_sequences2)


outp = Dense(classes_num, activation='sigmoid')(conc)

I am fitting like this:


But I am getting the error like: ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays PS: The training and validation vectors are arrays. But still I am getting the error. I think it might be because of the model definition but I am not sure.


Your network has two Inputs, so you need to pass in two arrays. From the rest of the code, perhaps you want to pass the same data through both strands, in which case you can just duplicate the input:

history=model.fit([trainDataVecs, trainDataVecs], ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.