jbryan
jbryan

Reputation: 15

Restoring correct version of tensorflow

A few weeks ago, I was working on a project and I installed an older version of tensorflow to try to fix a problem I was having. It didn't work as I had hoped and I pip install the newest version of tensorflow but now I'm regularly getting error messages related to tensorflow being out of date. They don't stop program execution but they are there. As far as I know, I have the most recent version installed but I think I must be missing something. This is an example of one of the errors I'm getting: WARNING: tensorflow: Can save best model only with val_loss available, skipping. This is happening when I try to save a keras model using ModelCheckpoint. I get a different message when I use model_save(). It seems the issues arise whenever I try to save any model in any way. If anyone has any advice, I would love it.

I'm using Python on Google Colab. Please let me know if you need more info from me.

Edit: Adding code for ModelCheckpoint:

save=ModelCheckpoint("/content/drive/My Drive/Colab Notebooks/cavity data/Frequency Model.h5", save_best_only=True, verbose=1)

it was then called in model.fit() like this:

model.fit(X_train, Y_train, epochs=500, callbacks=[save, stop], verbose=1)

Upvotes: 0

Views: 67

Answers (1)

S4rt-H4K
S4rt-H4K

Reputation: 109

The default monitor for ModelCheckpoint is the validation loss or "val_loss".

As the warning suggests, the key "val_loss" is missing because you didn't use validation data in model.fit().

Either specify the validation split or validation data in model.fit() or just use training loss or accuracy as a monitor for ModelCheckpoint as in my example below.

monitor = "accuracy"    # or "loss"
save = ModelCheckpoint("/content/drive/My Drive/Colab Notebooks/cavity data/Frequency Model.h5", monitor=monitor, save_best_only=True, verbose=1)

model.fit(X_train, Y_train, epochs=500, callbacks=[save, stop], verbose=1)

Upvotes: 1

Related Questions