title: How to concatenate two models in keras?
body: <p>I wanted to use this model but we cannot use merge anymore.</p>
  <pre><code>image_model = Sequential([
      Dense(embedding_size, input_shape=(2048,), activation='relu'),
      RepeatVector(max_len)
  ])
  caption_model = Sequential([
      Embedding(vocab_size, embedding_size, input_length=max_len),
      LSTM(256, return_sequences=True),
      TimeDistributed(Dense(300))
  ])
  final_model = Sequential([
      Merge([image_model, caption_model], mode='concat', concat_axis=1),
      Bidirectional(LSTM(256, return_sequences=False)),
      Dense(vocab_size),
      Activation('softmax')
  ])
  </code></pre>
  <p>i rewrote this in following way,excluding final_model:</p>
  <pre><code>image_in = Input(shape=(2048,))
  caption_in = Input(shape=(max_len, vocab_size))
  merged = concatenate([image_model(image_in), caption_model(caption_in)],axis=0)
  latent = Bidirectional(LSTM(256, return_sequences=False))(merged)
  out = Dense(vocab_size, activation='softmax')(latent)
  final_model = Model([image_in, caption_in], out)
  
  final_model.compile(loss='categorical_crossentropy', optimizer=RMSprop(), metrics=['accuracy'])
  final_model.summary()
  </code></pre>
  <p>This also gave me:</p>
  <pre><code>ValueError: &quot;input_length&quot; is 40, but received input has shape (None, 40, 8256).
  </code></pre>
  <p>Can anyone help to fix it?
  source:<a href="https://github.com/yashk2810/Image-Captioning/blob/master/Image%20Captioning%20InceptionV3.ipynb" rel="nofollow noreferrer">https://github.com/yashk2810/Image-Captioning/blob/master/Image%20Captioning%20InceptionV3.ipynb</a></p>