A pytorch implementation of the optimizer RAD
Project description
RAD (Relativistic Adaptive Gradient Descent)
Description
Training deep reinforcement learning (RL) agents necessitates overcoming the highly unstable nonconvex stochastic optimization inherent in the trial-and-error mechanism. To tackle this challenge, we propose a physics-inspired optimization algorithm called relativistic adaptive gradient descent (RAD), which enhances long-term training stability. By conceptualizing neural network (NN) training as the evolution of a conformal Hamiltonian system, we present a universal framework for transferring long-term stability from conformal symplectic integrators to iterative NN updating rules, where the choice of kinetic energy governs the dynamical properties of resulting optimization algorithms. By utilizing relativistic kinetic energy, RAD incorporates principles from special relativity and limits parameter updates below a finite speed, effectively mitigating abnormal gradient influences. Additionally, RAD models NN optimization as the evolution of a multi-particle system where each trainable parameter acts as an independent particle with an individual adaptive learning rate. We prove RAD's sublinear convergence under general nonconvex settings, where smaller gradient variance and larger batch sizes contribute to tighter convergence. Notably, RAD degrades to the well-known adaptive moment estimation (ADAM) algorithm when its speed coefficient is chosen as one and symplectic factor as a small fixed positive value. Experimental results on MuJoCo and Atari benchmarks show that RAD achieves state-of-the-art performance compared to cutting-edge optimizers, emphasizing its potential for stabilizing RL training.
Requirement
- Linux is preferred.
- Python 3.6 or greater.
- Pytorch installed.
Quick Start
Installing the package is straightforward with pip directly from this git repository or from pypi with either of the following commands.
pip install git+https://github.com/TobiasLv/RAD
pip install pytorch-rad
All optimizers have been implemented in the Python file "optimizers.py", including RAD, Adam, SGD (equaling HB when momentum is not 0), DLPF, NAG, RGD, NAdam, SWATS, AdamW. After installing the package, you can import any of these optimizers and use them in your code as any other torch.optim.Optimizer
from rad.optim import RAD, Adam, SGD, DLPF, RGD, NAG, NAdam, SWATS, AdamW
# Example usage:
# max_iter is optional, but recommended for fast convergence,
# usually as the maximum number of network updates.
rad_optim = RAD(net.parameters(), lr=0.001, max_iter=max_iter)
adam_optim = Adam(net.parameters(), lr=0.001)
hb_optim = SGD(net.parameters(), lr=0.001, momentum=0.9)
dlpf_optim = DLPF(net.parameters(), lr=0.001, momentum=0.9)
rgd_optim = RGD(net.parameters(), lr=0.001, momentum=0.9)
nag_optim = NAG(net.parameters(), lr=0.001, momentum=0.9)
sgd_optim = SGD(net.parameters(), lr=0.001, momentum=0)
nadam_optim = NAdam(net.parameters(), lr=0.001)
swats_optim = SWATS(net.parameters(), lr=0.001)
adamw_optim = AdamW(net.parameters(), lr=0.001)
Supplementary materials
Any user can find the supplementary in the "Supplementary materials" folder.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorch_rad-0.1.3.tar.gz.
File metadata
- Download URL: pytorch_rad-0.1.3.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d96e4e98d9a1b356d1000788daeb7d0994395e147dc040c9108615c6b3f14beb
|
|
| MD5 |
257104d89241a1f67f5c37265ecd5bde
|
|
| BLAKE2b-256 |
57aa5e3ef6d0ab1a04ea2c1d82b2ffab40f4703aca32b963a9e3fa18c9c145f7
|
File details
Details for the file pytorch_rad-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pytorch_rad-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02fa52da7d8aa2c42800b6a830edb5ca8dee81a56fae949de64fdfe49bd8c3a5
|
|
| MD5 |
5afb1fa28cdc322b2b2daf3675cb2026
|
|
| BLAKE2b-256 |
c1ff12443f853f5492f9f3041b024aecaecfb83865df4366fa16ae86e858dc32
|