Official implementation of the TRAC optimizer in Fast TRAC: A Parameter-Free Optimizer for Lifelong Reinforcement Learning.
Project description
TRAC: Adaptive Parameter-free Optimization ⚡️
This repository is the official implementation of the TRAC optimizer in Fast TRAC: A Parameter-Free Optimizer for Lifelong Reinforcement Learning.
How can you quickly adapt to new tasks or distribution shifts? Without knowing when or how much to adapt? And without ANY tuning? 🤔💭
Well, we suggest you get on the fast TRAC 🏎️💨.
TRAC is a parameter-free optimizer for continual environments inspired by online convex optimization and uses discounted adaptive online prediction.
Update [08/20/24]: TRAC is now supported for JAX and Optax!
Implement with only one line change with both PyTorch/JAX!
Like other meta-tuners, TRAC can work with any of your continual, fine-tuning, or lifelong experiments with just one line change.
pip install trac-optimizer
PyTorch
from trac import start_trac
# original optimizer
optimizer = torch.optim.Adam
lr = 0.001
optimizer = start_trac(log_file='logs/trac.text', optimizer)(model.parameters(), lr=lr)
JAX
from trac_optimizer.experimental.jax.trac import start_trac
# original optimizer
optimizer = optax.adam(1e-3)
optimizer = start_trac(optimizer)
After this modification, you can continue using your optimizer methods exactly as you did before. Whether it's calling optimizer.step()
to update your model's parameters or optimizer.zero_grad()
to clear gradients, everything stays the same. TRAC integrates into your existing workflow without any additional overhead.
Control Experiments
We recommend running main.ipynb
in Google Colab. This approach requires no setup, making it easy to get started with our control experiments. If you run locally, to install the necessary dependencies, simply:
pip install -r requirements.txt
Vision-based RL Experiments
Our vision-based experiments for Procgen and Atari are hosted in the vision_exp
directory, which is based off this Procgen Pytorch implementation.
To initiate an experiment with the default configuration in the Procgen "starpilot" environment, use the command below. You can easily switch to other game environments, like Atari, by altering the --exp_name="atari"
parameter:
python vision_exp/train.py --exp_name="procgen" --env_name="starpilot" --optimizer="TRAC" --warmstart_step=0
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 trac_optimizer-0.0.2.tar.gz
.
File metadata
- Download URL: trac_optimizer-0.0.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7456088a5e680981a24b7cf8a40051ead7b9691c3872d1c584158fcd110a71f7 |
|
MD5 | fd36e1d4d0478e1cbb5c42ed8a70c4df |
|
BLAKE2b-256 | b78a54bac599ea3ca707ae04487220389a7e4173b4df9a4370a727f338bc4dc3 |
File details
Details for the file trac_optimizer-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: trac_optimizer-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40114635764d77b2ac84f3ed0542df34f8df7c4502d99d6ce137170acf073c30 |
|
MD5 | 6fd2021cbdfc2fc59b74f2dfd4aa0c0a |
|
BLAKE2b-256 | d7510a207947ce80b875f46eaa17b63ab4b30fa7228321ebc3257440f123cd7a |