Skip to main content

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

  1. Linux is preferred.
  2. Python 3.6 or greater.
  3. Pytorch installed.

Quick Start

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. All of them can be used as any other torch.optim.Optimizer

from rad.optim import RAD, Adam, SGD, DLPF, RGD, NAG, NAdam, SWATS, AdamW

# Example usage:
rad_optim = RAD(net.parameters(), lr=0.001, eps_annealing=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

pytorch_rad-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytorch_rad-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pytorch_rad-0.1.1.tar.gz.

File metadata

  • Download URL: pytorch_rad-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for pytorch_rad-0.1.1.tar.gz
Algorithm Hash digest
SHA256 106887a526afca86be2bc2fca4ad690846f1dcc618ea50c16bb641dc23ecddb0
MD5 bfc1f9db0ed8128c87effe2268f14e99
BLAKE2b-256 c0b92b144ef2c08b2a3c8f05e8e105b00672afb7fd4c6227da20377de388d8ee

See more details on using hashes here.

File details

Details for the file pytorch_rad-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytorch_rad-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for pytorch_rad-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12b60af80adf215108ce83b4005a5636decc1dd8331a3b371a44a0a58f5ca3b6
MD5 2740393eabf0b926de071457de82aebf
BLAKE2b-256 48057dbdba03a096a0c9573e1c7183b415f0e71bec414c0b3429b6c65d086bd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page