Skip to content

Get the model from the best epoch? #2991

Answered by laggui
dpankova asked this question in Q&A

You must be logged in to vote

Hello! Is it correct that the model returned by the learner.fit is the model from the last epoch?

That is correct! The model returned is from its latest state (i.e., the last epoch update).

Is there a way to save the model from the epoch with the best loss?

By default, the learner already keeps the best 2 checkpoints based on the validation loss

checkpointer_strategy: Box::new(
ComposedCheckpointingStrategy::builder()
.add(KeepLastNCheckpoints::new(2))
.add(MetricCheckpointingStrategy::new(
&LossMetric::<B>::new(), // default to valid loss
Aggregate::Mean,
Direction::Lowest,

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@dpankova

Answer selected by dpankova
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants