-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WARNING:tensorflow:Can save best model only with val_loss available, skipping. #44107
Comments
As stated here, monitor argument has to match one of the metric names passed at the metrics argument of model.compile(). So, you need to add tf.keras.metrics.SparseCategoricalCrossentropy to your metrics list (but this will print loss twice at each epoch) and "sparse_categorical_crossentropy" to monitor. But, this is not a solution, since this monitors the train set loss. I tried prepending val_ ("val_sparse_categorical_crossentropy"), which is a valid monitor being printed at each epoch, but got the same error. |
@alexliyihao |
Ah sorry, the complete code is a part of wrapped code and it took me a while to extract them out, a complete reproducible code is like following: you can run it in https://colab.research.google.com/drive/1glZ4Mm5mo-Ev3YI9IlucfNH43AVZLFm0?usp=sharing ,I just have it run on normal Colab Notebook, the warning popped up as well. Not sure about local because my old macbook cannot handle much training= =
|
@alexalemi |
The data is some project-specific data so I'm afraid that I cannot provide the actual one, but I can confirm that the issue still exist. Verbose = 1 will create this multi-line format in jupyter notebook, therefore I'm using tqdm.keras.TqdmCallback for most of the time. This is the output for 2 epochs when not using tqdm.keras.TqdmCallback, but using verbose = 1 for both fit() and ModelCheckpoint. What can be also stated is that I tried tf.data.Dataset in
|
Hello I am having exactly the same error.
nvidia-smi
Running in nvidia docker THE CODE:
Keys of hist.history
When running I receive the following warning:
I tried to change
But I receive the same warning: |
It just found the solution to my problem. "save_freq" was set to 5 meaning it would save the model at each batch if val_acc improved. But as val_acc is computed after each epoch it didn't get any info on how each batch did. Changing to |
I changed |
Closing this issue since the following setting helps resolves the problem for many users. Thank you.
|
save_freq was called period in the previous version |
I can't fixed using "save_freq='epoch'". Epoch need's to be a value or it's only a string? |
You will need to set epoch=some value prior to using save_freq='epoch' . For instance, epoch = 5, save_freq = 'epoch' |
System information
Current Google Colab Pro notebook, Tensorflow version 2.3.0
Describe the current behavior
when running .fit() with callback.ModelCheckpoint monitoring both
val_loss
andval_sparse_categorical_accuracy
the "WARNING:tensorflow:Can save best model only with val_loss available, skipping." pops up even if both terms are in hist.history returned from fitDescribe the expected behavior
Standalone code to reproduce the issue
where data are np.ndarray, and
returns the following:
loss
sparse_categorical_accuracy
val_loss
val_sparse_categorical_accuracy
lr
The text was updated successfully, but these errors were encountered: