I create a LSTM model consist of 2 layers and output layer. ten i predict test data on it and compute mape error.
I saved this model to be used as pre-trained model and freeze the two layer then reuse the dense layer to predict same test data but got different mape error.
Is not logic that i have same value of error.
trainx3, trainy3, testx3 are the same for pretained saved model
new_model = tf.keras.models.load_model('saved_model/my_model')
new_model.summary()
#new_model.trainable=False
new_model.get_layer('lstm').trainable = False
new_model.get_layer('lstm_1').trainable = False
#yhat3 = new_model.predict(test_X3, batch_size=1)
base_inputs=new_model.layers[0].input
base_outputs=new_model.layers[-2].output
final_outputs=layers.Dense(56)(base_outputs)
now_model=keras.Model(inputs=base_inputs, outputs=final_outputs)
now_model.compile(loss='mean_squared_error', optimizer='adam')
now_model.fit(train_X3, train_y3, epochs=5, batch_size=1,verbose=2)
yhat3 = now_model.predict(test_X3, batch_size=1)