Hi All, how to two models concatenate or marge model1 & model2 both are written in TensorFlow. Please help me with this issue.
-------------------------Model 1 --> LSTM Model---------------------------------
model1 = tf.keras.Sequential([
tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length = max_length),
tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(32)),
tf.keras.layers.Dense(1, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model1.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])
# history1 = model1.fit(training_padded, training_labels, epochs=2, validation_data=(testing_padded, testing_labels), verbose=2)
score,acc=model1.evaluate(testing_padded,testing_labels)
acc,score
#RNN Model
print('''
-------------------------Model 2 --> RNN Model---------------------------------
''')
model2 = tf.keras.Sequential([
tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length=max_length),
tf.keras.layers.Bidirectional(tf.keras.layers.SimpleRNN(50, return_sequences=True,input_shape=(max_length, embedding_dim))),
tf.keras.layers.Dropout(0.5),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model2.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])
history2 = model2.fit(training_padded, training_labels, epochs=2, validation_data=(testing_padded, testing_labels), verbose=2)
score,acc=model2.evaluate(testing_padded,testing_labels)
acc,score