Hi. I have a code which is concatenating two models. The code used the old version of Keras. I am using Keras 2.2.4. I am trying to concatenate both the models but I am getting an error while training. And if I use the pre-train model and try to execute the test file I get the following error:

ValueError: You are trying to load a weight file containing 6 layers into a model with 0 layers.

Because of this error, I am assuming that I am not concatenating the models correctly. Here is my code snippet. How do I concatenate my model using Keras 2.2.4 on line

"model.add(Merge([image_model, lang_model], mode='concat'))" .... Below is the complete model code snippet.

def create_model(self, ret_model = False):

image_model = Sequential()

image_model.add(Dense(EMBEDDING_DIM, input_dim = 4096, activation='relu'))

image_model.add(RepeatVector(self.max_length))

lang_model = Sequential()

lang_model.add(Embedding(self.vocab_size, 256, input_length=self.max_length))

lang_model.add(LSTM(256,return_sequences=True))

lang_model.add(TimeDistributed(Dense(EMBEDDING_DIM)))

model = Sequential()

model.add(Merge([image_model, lang_model], mode='concat'))

model.add(LSTM(1000,return_sequences=False))

model.add(Dense(self.vocab_size))

model.add(Activation('softmax'))

print ("Model created!")

if(ret_model==True):

return model

model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

return model

Here is my code snippet in pic: How do I concatenate my model using Keras 2.2.4 on line 103.