pytorch Torch lightning :如何为每个验证时期保存一个检查点?

x8goxv8g  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(100)

the docs中不清楚如何为每个epoch保存检查点,并且实际保存它而不是立即删除,没有后续指标。
怎么做?

xytpbqjk

xytpbqjk1#

max_epochs = 100
val_every_n_epochs = 1

checkpoint_callback = ModelCheckpoint(
        # dirpath=checkpoints_path, # <--- specify this on the trainer itself for version control
        filename="fa_classifier_{epoch:02d}",
        every_n_epochs=val_every_n_epochs,
        save_top_k=-1,  # <--- this is important!
    )
 trainer = Trainer(
        callbacks=[checkpoint_callback],     
        default_root_dir=checkpoints_path,
        check_val_every_n_epoch=val_every_n_epochs,
        max_epochs=max_epochs,
        gpus=1
    )

这不会删除保存的检查点。

相关问题