-
-
Notifications
You must be signed in to change notification settings - Fork 654
Closed
Description
🚀 Feature
Currently, if we execute twice trainer.run
we can fall into the following situation:
# ...
trainer.run(train_loader, max_epochs=5)
# reset model weights etc and rerun
trainer.run(train_loader, max_epochs=2)
> ValueError: Argument max_epochs should be larger than the start epoch defined in the state: 2 vs 5
But if we would like to restart the training from the begining, we have to reset trainer.state
as
trainer.run(train_loader, max_epochs=5)
# reset model weights etc and rerun
trainer.state.max_epochs = None
trainer.run(train_loader, max_epochs=2)
Let's improve two things:
- let's provide
State.restart()
method that just setsstate.max_epochs = None
- Add a note into
Engine.run
docstring saying if we would like to restart the training from zero, we have to either calltrainer.state.restart()
ortrainer.state.max_epochs = None
. - Improve the message "ValueError: Argument max_epochs should be larger than the start epoch defined in the state: 2 vs 5" by adding something like "Please, call state.restart() before calling engine.run() if would like to restart from zero."
For Hacktoberfest contributors, feel free to ask questions for details if any and say that you would like to tackle the issue.
Please, take a look at CONTRIBUTING guide.
sdesrozis