Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keras/src/callbacks/model_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ def _save_model(self, epoch, batch, logs):
self.model.save_weights(filepath, overwrite=True)
else:
self.model.save(filepath, overwrite=True)
if self.verbose > 0:
io_utils.print_msg(
f"\nEpoch {epoch + 1}: finished saving model to {filepath}"
)
Comment on lines 286 to 290
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This new log message is useful for timing the save operation. However, in its current form, it can lead to inconsistent logging output.

The "finished saving" message will be printed whenever a model is saved and verbose > 0. However, the corresponding "starting to save" message is not always printed under the same conditions.

Specifically, in _should_save_model, when save_best_only=True and the monitor metric is unavailable or not a scalar, the method returns True (triggering a save) but only issues a warning, not a verbose log message. This results in an "end" log without a "start" log, which could be confusing for users.

To ensure consistent logging, a "starting to save" message should also be logged in these fallback cases within _should_save_model. This would ensure that every "finished saving" log is paired with a "saving" log when verbose > 0.

except IsADirectoryError: # h5py 3.x
raise IOError(
"Please specify a non-directory filepath for "
Expand Down
Loading