title: Seq2Seq Bidirectional Encoder Decoder in Keras
body: <p>I am trying to implement a seq2seq encoder-decoder using Keras, with bidirectional lstm on the encoder as follows:</p>
  
  
  
  <pre class="lang-py prettyprint-override"><code>from keras.layers import LSTM,Bidirectional,Input,Concatenate
  from keras.models import Model
  
  n_units = 8
  n_input = 1
  n_output = 1
  
  # encoder
  encoder_inputs = Input(shape=(None, n_input))
  encoder = Bidirectional(LSTM(n_units, return_state=True))
  encoder_outputs, forward_h, forward_c, backward_h, backward_c = encoder(encoder_inputs)
  state_h = Concatenate()([forward_h, backward_h])
  state_c = Concatenate()([forward_c, backward_c])
  encoder_states = [state_h, state_c]
  
  # decoder
  decoder_inputs = Input(shape=(None, n_output))    
  decoder_lstm = LSTM(n_units*2, return_sequences=True, return_state=True)
  decoder_outputs, _, _ = decoder_lstm(decoder_inputs, initial_state=encoder_states)
  </code></pre>
  
  <p>Here is the following error I got on the last line:</p>
  
  <pre class="lang-py prettyprint-override"><code>ValueError: Dimensions must be equal, but are 8 and 16 for 
  'lstm_2_1/MatMul_4' (op: 'MatMul') with input shapes: [?,8], [16,16].
  </code></pre>
  
  <p>Any ideas? </p>