Deployed 2425ef0 with MkDocs version: 1.0.4

This commit is contained in:
William Falcon
2019-08-07 15:02:23 -05:00
parent 6ccd5b10ac
commit d43f670f3c
3 changed files with 33 additions and 4 deletions
+32 -3
View File
@@ -572,10 +572,39 @@ However, the dataloaders will start from the first batch again (if you shuffled
<pre><code class="python">from test_tube import Experiment
exp = Experiment(version=a_previous_version_with_a_saved_checkpoint)
Trainer(experiment=exp)
trainer = Trainer(experiment=exp)
trainer = Trainer(checkpoint_callback=checkpoint_callback)
# the trainer is now restored
# this fit call loads model weights and trainer state
# the trainer continues seamlessly from where you left off
# without having to do anything else.
trainer.fit(model)
</code></pre>
<p>The trainer restores:<br />
- global_step <br />
- current_epoch <br />
- All optimizers <br />
- All lr_schedulers <br />
- Model weights</p>
<p>You can even change the logic of your model as long as the weights and "architecture" of
the system isn't different. If you add a layer, for instance, it might not work. </p>
<p>At a rough level, here's <a href="https://github.com/williamFalcon/pytorch-lightning/blob/master/pytorch_lightning/root_module/model_saving.py#L63">what happens inside Trainer</a>: </p>
<pre><code class="python">
self.global_step = checkpoint['global_step']
self.current_epoch = checkpoint['epoch']
# restore the optimizers
optimizer_states = checkpoint['optimizer_states']
for optimizer, opt_state in zip(self.optimizers, optimizer_states):
optimizer.load_state_dict(opt_state)
# restore the lr schedulers
lr_schedulers = checkpoint['lr_schedulers']
for scheduler, lrs_state in zip(self.lr_schedulers, lr_schedulers):
scheduler.load_state_dict(lrs_state)
# uses the model you passed into trainer
model.load_state_dict(checkpoint['state_dict'])
</code></pre>
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.