Skip to content

when I configure callbacks in the model instead of in the Trainer function, will the model look for the best model or the current model when testing? #13611

Discussion options

You must be logged in to vote

Does the model use the parameters at the last epoch when testing, or the best parameters loaded?

Hi @Struggle-Forever, yes, the model is in the last state, but not in the best state. I hope the following example in the documentation will explain it enough:

# run full training
trainer.fit(model)

# (1) load the best checkpoint automatically (lightning tracks this for you)
trainer.test(ckpt_path="best")

# (2) test using a specific checkpoint
trainer.test(ckpt_path="/path/to/my_checkpoint.ckpt")

# (3) test with an explicit model (will use this model and not load a checkpoint)
trainer.test(model)

https://pytorch-lightning.readthedocs.io/en/1.6.4/common/evaluation.html#test-after-fit

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Struggle-Forever
Comment options

Answer selected by akihironitta
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment