Skip to content

Commit 78c729e

Browse files
authored
Fix callback (#21349)
* Fix callback * Nah * Revert prev changes, fix logging
1 parent c7b66fc commit 78c729e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

keras/src/callbacks/model_checkpoint.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ def _should_save_model(self, epoch, batch, logs, filepath):
237237
)
238238
return True
239239
else:
240+
best_str = "None" if self.best is None else f"{self.best:.5f}"
240241
if self._is_improvement(current, self.best):
241242
if self.verbose > 0:
242243
io_utils.print_msg(
243244
f"\nEpoch {epoch + 1}: {self.monitor} "
244-
"improved "
245-
f"from {self.best:.5f} to {current:.5f}, "
245+
f"improved from {best_str} to {current:.5f}, "
246246
f"saving model to {filepath}"
247247
)
248248
self.best = current
@@ -251,8 +251,7 @@ def _should_save_model(self, epoch, batch, logs, filepath):
251251
if self.verbose > 0:
252252
io_utils.print_msg(
253253
f"\nEpoch {epoch + 1}: "
254-
f"{self.monitor} did not improve "
255-
f"from {self.best:.5f}"
254+
f"{self.monitor} did not improve from {best_str}"
256255
)
257256
return False
258257
else:

0 commit comments

Comments
 (0)