Deployed 0ce180f with MkDocs version: 1.0.4

This commit is contained in:
William Falcon
2019-07-26 22:24:14 -05:00
parent 0985c7a1ca
commit 3007636435
5 changed files with 44 additions and 44 deletions
@@ -317,8 +317,8 @@
</li>
<li class="md-nav__item">
<a href="#get_save_dict" title="get_save_dict" class="md-nav__link">
get_save_dict
<a href="#on_save_checkpoint" title="on_save_checkpoint" class="md-nav__link">
on_save_checkpoint
</a>
<nav class="md-nav">
@@ -337,8 +337,8 @@
</li>
<li class="md-nav__item">
<a href="#load_model_specific" title="load_model_specific" class="md-nav__link">
load_model_specific
<a href="#on_load_checkpoint" title="on_load_checkpoint" class="md-nav__link">
on_load_checkpoint
</a>
<nav class="md-nav">
@@ -726,8 +726,8 @@
</li>
<li class="md-nav__item">
<a href="#get_save_dict" title="get_save_dict" class="md-nav__link">
get_save_dict
<a href="#on_save_checkpoint" title="on_save_checkpoint" class="md-nav__link">
on_save_checkpoint
</a>
<nav class="md-nav">
@@ -746,8 +746,8 @@
</li>
<li class="md-nav__item">
<a href="#load_model_specific" title="load_model_specific" class="md-nav__link">
load_model_specific
<a href="#on_load_checkpoint" title="on_load_checkpoint" class="md-nav__link">
on_load_checkpoint
</a>
<nav class="md-nav">
@@ -899,10 +899,6 @@
<li>
<p><a href="./#configure_optimizers">configure_optimizers</a></p>
</li>
<li><a href="./#get_save_dict">get_save_dict</a></li>
<li>
<p><a href="./#load_model_specific">load_model_specific</a></p>
</li>
<li>
<p><a href="./#tng_dataloader">tng_dataloader</a></p>
</li>
@@ -911,6 +907,8 @@
</ul>
<p><strong>Optional</strong>: </p>
<ul>
<li><a href="./#on_save_checkpoint">on_save_checkpoint</a></li>
<li><a href="./#on_load_checkpoint">on_load_checkpoint</a></li>
<li><a href="./#update_tng_log_metrics">update_tng_log_metrics</a></li>
<li><a href="./#add_model_specific_args">add_model_specific_args</a></li>
</ul>
@@ -1176,34 +1174,35 @@ def configure_optimizers(self):
</code></pre>
<hr />
<h3 id="get_save_dict">get_save_dict</h3>
<pre><code class="python">def get_save_dict(self)
<h3 id="on_save_checkpoint">on_save_checkpoint</h3>
<pre><code class="python">def on_save_checkpoint(self, checkpoint)
</code></pre>
<p>Called by lightning to checkpoint your model. Lightning saves current epoch, current batch nb, etc...
All you have to return is what specifically about your lightning model you want to checkpoint.</p>
<p>Called by lightning to checkpoint your model. Lightning saves the training state (current epoch, global_step, etc)
and also saves the model state_dict. If you want to save anything else, use this method to add your own
key-value pair.</p>
<h5 id="return_1">Return</h5>
<p>Dictionary - No required keys. Most of the time as described in this example. </p>
<p>Nothing</p>
<p><strong>Example</strong></p>
<pre><code class="python">def get_save_dict(self):
# 99% of use cases this is all you need to return
checkpoint = {'state_dict': self.state_dict()}
return checkpoint
<pre><code class="python">def on_save_checkpoint(self, checkpoint):
# 99% of use cases you don't need to implement this method
checkpoint['something_cool_i_want_to_save'] = my_cool_pickable_object
</code></pre>
<hr />
<h3 id="load_model_specific">load_model_specific</h3>
<pre><code class="python">def load_model_specific(self, checkpoint)
<h3 id="on_load_checkpoint">on_load_checkpoint</h3>
<pre><code class="python">def on_load_checkpoint(self, checkpoint)
</code></pre>
<p>Called by lightning to restore your model. This is your chance to restore your model using the keys you added in get_save_dict.
Lightning will automatically restore current epoch, batch nb, etc. </p>
<p>Called by lightning to restore your model. Lighting auto-restores global step, epoch, etc...
It also restores the model state_dict.
If you saved something with <strong>on_save_checkpoint</strong> this is your chance to restore this.</p>
<h5 id="return_2">Return</h5>
<p>Nothing </p>
<p><strong>Example</strong></p>
<pre><code class="python">def load_model_specific(self, checkpoint):
# you defined 'state_dict' in get_save_dict()
self.load_state_dict(checkpoint['state_dict'])
<pre><code class="python">def on_load_checkpoint(self, checkpoint):
# 99% of the time you don't need to implement this method
self.something_cool_i_want_to_save = checkpoint['something_cool_i_want_to_save']
</code></pre>
<hr />