Skip to content

Commit

Permalink
docs: usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kozistr committed Nov 15, 2021
1 parent 4ee7d25 commit c92f236
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ Simple Usage

::

from pytorch_optimizer import Ranger21
from pytorch_optimizer import AdamP

...
model = YourModel()
optimizer = Ranger21(model.parameters())
optimizer = AdamP(model.parameters())
...

for input, output in data:
optimizer.zero_grad()
loss = loss_function(output, model(input))
loss.backward()
optimizer.step()
or you can use optimizer loader, simply passing a name of the optimizer.

::

from pytorch_optimizer import load_optimizers

...
model = YourModel()
opt = load_optimizers(optimizer='adamp', use_fp16=True)
optimizer = opt(model.parameters())
...

Supported Optimizers
--------------------
Expand Down

0 comments on commit c92f236

Please sign in to comment.