Skip to content

Commit 0540544

Browse files
committed
info about saving latest checkpoint only in on_train_end callback stage
1 parent b880ad8 commit 0540544

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pytorch_lightning/callbacks/model_checkpoint.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def save_checkpoint(self, trainer, pl_module, is_last=False):
277277
self._save_top_k_checkpoints(trainer, pl_module, monitor_candidates)
278278

279279
# Mode 2: save the last checkpoint
280-
self._save_last_checkpoint(trainer, pl_module, monitor_candidates)
280+
self._save_last_checkpoint(trainer, pl_module, monitor_candidates, is_last=is_last)
281281

282282
def __validate_init_configuration(self):
283283
if self.save_top_k is not None and self.save_top_k < -1:
@@ -571,14 +571,15 @@ def _monitor_candidates(self, trainer):
571571
ckpt_name_metrics.update({"step": trainer.global_step, "epoch": trainer.current_epoch})
572572
return ckpt_name_metrics
573573

574-
def _save_last_checkpoint(self, trainer, pl_module, ckpt_name_metrics):
574+
def _save_last_checkpoint(self, trainer, pl_module, ckpt_name_metrics, is_last=False):
575575
should_save_last = self.monitor is None or self.save_last
576576
if not should_save_last:
577577
return
578578

579579
# when user ALSO asked for the 'last.ckpt' change the name
580580
if self.save_last:
581-
rank_zero_info("Saving latest checkpoint...")
581+
if is_last:
582+
rank_zero_info("Saving latest checkpoint...")
582583
last_filepath = self._format_checkpoint_name(
583584
self.CHECKPOINT_NAME_LAST,
584585
trainer.current_epoch,

0 commit comments

Comments
 (0)