mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-20 13:10:42 +08:00
Deployed 09d4475 with MkDocs version: 1.0.4
This commit is contained in:
@@ -546,11 +546,11 @@
|
||||
|
||||
<h1>Checkpointing</h1>
|
||||
|
||||
<p>Lightning can automate saving and loading checkpoints.</p>
|
||||
<p>i Lightning can automate saving and loading checkpoints.</p>
|
||||
<hr />
|
||||
<h3 id="model-saving">Model saving</h3>
|
||||
<p>To enable checkpointing, define the checkpoint callback and give it to the trainer.</p>
|
||||
<pre><code class="python">from pytorch_lightning.utils.pt_callbacks import ModelCheckpoint
|
||||
<pre><code class="python">from pytorch_lightning.callbacks import ModelCheckpoint
|
||||
|
||||
checkpoint_callback = ModelCheckpoint(
|
||||
filepath='/path/to/store/weights.ckpt',
|
||||
|
||||
@@ -627,9 +627,13 @@ trainer = Trainer(enable_early_stop=True)
|
||||
|
||||
<hr />
|
||||
<h4 id="gradient-clipping">Gradient Clipping</h4>
|
||||
<p>Use this to turn off early stopping and run training to the <a href="#force-training-for-min-or-max-epochs">max_epoch</a></p>
|
||||
<p>Gradient clipping may be enabled to avoid exploding gradients.
|
||||
Specifically, this will <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.utils.clip_grad_norm_">clip the gradient norm computed over all model parameters <em>together</em></a>.</p>
|
||||
<pre><code class="python"># DEFAULT (ie: don't clip)
|
||||
trainer = Trainer(gradient_clip=0)
|
||||
|
||||
# clip gradients with norm above 0.5
|
||||
trainer = Trainer(gradient_clip=0.5)
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
|
||||
Reference in New Issue
Block a user