mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-09 11:32:07 +08:00
Deployed db0d347 with MkDocs version: 1.0.4
This commit is contained in:
@@ -1173,21 +1173,22 @@ This is most likely the same as your training_step. But unlike training step, th
|
||||
<pre><code class="python">def configure_optimizers(self)
|
||||
</code></pre>
|
||||
|
||||
<p>Set up as many optimizers as you need. Normally you'd need one. But in the case of GANs or something more esoteric you might have multiple.
|
||||
Lightning will call .backward() and .step() on each one. If you use 16 bit precision it will also handle that.</p>
|
||||
<p>Set up as many optimizers and (optionally) learning rate schedulers as you need. Normally you'd need one. But in the case of GANs or something more esoteric you might have multiple.
|
||||
Lightning will call .backward() and .step() on each one in every epoch. If you use 16 bit precision it will also handle that.</p>
|
||||
<h5 id="return">Return</h5>
|
||||
<p>List - List of optimizers</p>
|
||||
<p>List or Tuple - List of optimizers with an optional second list of learning-rate schedulers</p>
|
||||
<p><strong>Example</strong></p>
|
||||
<pre><code class="python"># most cases
|
||||
def configure_optimizers(self):
|
||||
opt = Adam(lr=0.01)
|
||||
opt = Adam(self.parameters(), lr=0.01)
|
||||
return [opt]
|
||||
|
||||
# gan example
|
||||
# gan example, with scheduler for discriminator
|
||||
def configure_optimizers(self):
|
||||
generator_opt = Adam(lr=0.01)
|
||||
disriminator_opt = Adam(lr=0.02)
|
||||
return [generator_opt, disriminator_opt]
|
||||
generator_opt = Adam(self.model_gen.parameters(), lr=0.01)
|
||||
disriminator_opt = Adam(self.model_disc.parameters(), lr=0.02)
|
||||
discriminator_sched = CosineAnnealing(discriminator_opt, T_max=10)
|
||||
return [generator_opt, disriminator_opt], [discriminator_sched]
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
|
||||
Reference in New Issue
Block a user