Bunch of optimizer implementations in PyTorch with clean-code, strict types. Also, including useful optimization ideas.
Project description
Build |
|
Quality |
|
Package |
|
Status |
Documentation
Usage
Install
$ pip3 install -U pytorch-optimizer
or
$ pip3 install -U --no-deps pytorch-optimizer
Simple Usage
from pytorch_optimizer import AdamP model = YourModel() optimizer = AdamP(model.parameters()) # or you can use optimizer loader, simply passing a name of the optimizer. from pytorch_optimizer import load_optimizer model = YourModel() opt = load_optimizer(optimizer='adamp') optimizer = opt(model.parameters())
Also, you can load the optimizer via torch.hub
import torch model = YourModel() opt = torch.hub.load('kozistr/pytorch_optimizer', 'adamp') optimizer = opt(model.parameters())
And you can check the supported optimizers & lr schedulers.
from pytorch_optimizer import get_supported_optimizers, get_supported_lr_schedulers supported_optimizers = get_supported_optimizers() supported_lr_schedulers = get_supported_lr_schedulers()
Supported Optimizers
Optimizer |
Description |
Official Code |
Paper |
---|---|---|---|
AdaBelief |
Adapting Step-sizes by the Belief in Observed Gradients |
||
AdaBound |
Adaptive Gradient Methods with Dynamic Bound of Learning Rate |
||
AdaHessian |
An Adaptive Second Order Optimizer for Machine Learning |
||
AdamD |
Improved bias-correction in Adam |
||
AdamP |
Slowing Down the Slowdown for Momentum Optimizers on Scale-invariant Weights |
||
diffGrad |
An Optimization Method for Convolutional Neural Networks |
||
MADGRAD |
A Momentumized, Adaptive, Dual Averaged Gradient Method for Stochastic |
||
RAdam |
On the Variance of the Adaptive Learning Rate and Beyond |
||
Ranger |
a synergistic optimizer combining RAdam and LookAhead, and now GC in one optimizer |
||
Ranger21 |
a synergistic deep learning optimizer |
||
Lamb |
Large Batch Optimization for Deep Learning |
||
Shampoo |
Preconditioned Stochastic Tensor Optimization |
||
Nero |
Learning by Turning: Neural Architecture Aware Optimisation |
||
Adan |
Adaptive Nesterov Momentum Algorithm for Faster Optimizing Deep Models |
||
Adai |
Disentangling the Effects of Adaptive Learning Rate and Momentum |
Useful Resources
Several optimization ideas to regularize & stabilize the training. Most of the ideas are applied in Ranger21 optimizer.
Also, most of the captures are taken from Ranger21 paper.
Adaptive Gradient Clipping
Gradient Centralization
Gradient Centralization (GC) operates directly on gradients by centralizing the gradient to have zero mean.
Softplus Transformation
By running the final variance denom through the softplus function, it lifts extremely tiny values to keep them viable.
paper : arXiv
Gradient Normalization
Norm Loss
paper : arXiv
Positive-Negative Momentum
Linear learning rate warmup
paper : arXiv
Stable weight decay
Explore-exploit learning rate schedule
Lookahead
Chebyshev learning rate schedule
Acceleration via Fractal Learning Rate Schedules
paper : arXiv
(Adaptive) Sharpness-Aware Minimization
On the Convergence of Adam and Beyond
paper : paper
Gradient Surgery for Multi-Task Learning
paper : paper
Citations
Explore-Exploit Learning Rate Schedule
On the adequacy of untuned warmup for adaptive optimization
Stable weight decay regularization
Adaptive Sharpness-aware minimization
On the Convergence of Adam and Beyond
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytorch_optimizer-2.1.0.tar.gz
.
File metadata
- Download URL: pytorch_optimizer-2.1.0.tar.gz
- Upload date:
- Size: 39.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72d3a7e6057b6ec30a14a593013e7179ef3d2905d2fe37ee0362ab8fbc312a5a |
|
MD5 | 27d14384632e951eea1854041ce4c941 |
|
BLAKE2b-256 | b1d7478667ef095544b414e4ee85a7c36318243b9a2a5b8418dac0fd9f9235f1 |
File details
Details for the file pytorch_optimizer-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytorch_optimizer-2.1.0-py3-none-any.whl
- Upload date:
- Size: 62.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff43262f70c8e449f7bff303f7ea6d88fe0bc3e68f298bafb5fb8c15ae453405 |
|
MD5 | 7978ba5ab7e303d7ec16e715ea92b9d7 |
|
BLAKE2b-256 | 5028bb81842bd975efadfd60ad519da9c86e70dcf31c2719509f3bd725cd2157 |