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
-
A question: when I configure callbacks in the model instead of in the Train function, will the model look for the best model or the current model when testing? For example: configure the configure_callbacks in my model
` Not configure the configure_callbacks in the Trainer When i perform the trainer like this:
` My question is: Does the model use the parameters at the last epoch when testing, or the best parameters loaded? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @Struggle-Forever, yes, the # 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 |
Beta Was this translation helpful? Give feedback.
-
thank you very much! |
Beta Was this translation helpful? Give feedback.
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:https://pytorch-lightning.readthedocs.io/en/1.6.4/common/evaluation.html#test-after-fit