Skip to content

Commit

Permalink
Set initial epoch and set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaysoni committed Jan 17, 2020
1 parent 9f11bc3 commit 0227a65
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions farm/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def __init__(
checkpoint_on_sigkill=False,
checkpoint_every=None,
checkpoint_root_dir=None,
from_epoch=1,
from_step=1,
from_epoch=0,
from_step=0,
):
"""
:param optimizer: An optimizer object that determines the learning strategy to be used during training
Expand Down Expand Up @@ -270,6 +270,9 @@ def _load_checkpoint(cls, path, data_silo):
trainer_checkpoint = torch.load(path / "trainer")
trainer_state_dict = trainer_checkpoint["trainer_state_dict"]

# Just setting seeds is not sufficient to have deterministic results when resuming
# training from a checkpoint. Additionally, the previous states of Random Number
# Generators also need to be restored from the saved checkpoint.
numpy_rng_state = trainer_checkpoint["numpy_rng_state"]
numpy.random.set_state(numpy_rng_state)
rng_state = trainer_checkpoint["rng_state"]
Expand Down

0 comments on commit 0227a65

Please sign in to comment.