I have 2 different set of features, for which I have created 2 separate Sequential models, something like this:
model1 = Sequential()
model1.add(Embedding(self.max_words, self.embedding_dim))
model1.add(LSTM(32))
and
model2 = Sequential()
model2.add(Dense(64, activation='relu', input_shape=(num_features,)))
model2.add(Dense(32, activation='relu'))
Finally, I'm concatenating these 2 models like this:
merged_model = Sequential()
merged_model.add(Concatenate([model1, model2]))
merged_model.add(Dense(1, activation='sigmoid'))
merged_model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
However, I'm confused about what the 'fit' code would look like, as we need to have 2 separate x_train datasets in merged_model. Is this the correct way to do this:
history = merged_model.fit([x_train1, x_train2], y_train, epochs=10, batch_size=128, validation_split=0.2)
Also, is this the correct way to concatenate 2 layers if we want to merge 2 parallel models ?