Load weights from TensorFlow checkpoint to Keras model

Viewed 3635

I have trained a TensorFlow with Keras model and using keras.callbacks.ModelCheckpoint I've saved the weights as follows:

cp_callback = keras.callbacks.ModelCheckpoint(checkpoint_path,
                                          save_weights_only=True,
                                          verbose=1)
model.fit(X_train, Y_train, callbacks=[cp_callback], epochs=50, batch_size=256)

But while trying to load the saved weights there is nothing changed to my model, after building the model architecture and compile it I load weights as follows:

model.load_weights('./checkpoints/cp.ckpt')

But nothing happens, the testing accuracy is as random guessing, while my real testing accuracy is 80.49%

The model consists of keras dence layers with l2 kernel_regularizer and glorot kernel_initializer, also I'm using TensorFlow version 1.12.0, any ideas?

0 Answers
Related