Package: dopamax
DopamaxDopamax is a library containing pureJAXimplementations of common reinforcement learning algorithms.Everythingis implemented in JAX, including the environments. This allows for extremely fast training and evaluation of agents,
because the entire loop of environment simulation, agent interaction, and policy updates can be compiled as a single
XLA program and executed on CPUs, GPUs, or TPUs. More specifically, the implementations in Dopamax follow the
Anakin Podracer architecture -- seethis paperfor more details.Note that this repository is not actively maintained and is subject to breaking changes at any time.Supported AlgorithmsProximal Policy Optimization (PPO)Deep Q-Network (DQN)AlphaZeroInstallationDopamax can be installed with:pipinstalldopamaxThis will install thedopamaxPython package, as well as a command-line interface (CLI) for training and evaluation.
Note that only the CPU version of JAX is installed by default. If you would like to use a GPU or TPU, you will need to
install the appropriate version of JAX. See theJAX installation instructions.UsageAfter installation, the Dopamax CLI can be used to train and evaluate agents:dopamax--helpDopamax usesWeights and Biases (W&B)for logging and artifact management. Before using the CLI
for training and evaluation, you must first make sure you have a W&B account (it's free) and have authenticated
withwandb login.TrainingAgent's can be trained using thedopamax traincommand, to which you must provide a configuration file. The
configuration file is a YAML file that specifies the agent, environment, and training hyperparameters. You can find
examples in theconfigsdirectory. For example, to train a PPO agent on the CartPole environment, you would
run:dopamaxtrain--configexamples/ppo-cartpole/config.yamlNote that all of the example config files have a random seed specified, so you will get the same result every time you
run the command. The seeds provided in the examples are known to result in a successful run (with the given
hyperparameters). To get different results on each run, you can remove the seed from the config file.EvaluationOnce you have trained some agents, you can evaluate them using thedopamax evaluatecommand. This will allow you to
specify a W&B agent artifact that you'd like to evaluate (these artifacts are produced by the training runs and
contain the agent hyperparameters and weights from the end of training). For example, to evaluate a PPO agent trained
on CartPole, you might use a command like:dopamaxevaluate--agent_artifactCartPole-PPO-agent:v0--num_episodes100where--num_episodes 100signals that you would like to rollout the agent's policy for 100 episodes. The minimum,
mean, and maximum episode reward will be logged back to W&B. If you would additionally like to render the episodes and
have then logged back to W&B, you can provide the--renderflag. But note that this will usually significantly slow
down the evaluation process since environment rendering is not a pure JAX function and requires callbacks to the host.
You should usually only use the--renderflag with a small number of episodes.See AlsoSome of the JAX-native packages that Dopamax relies on:sotetsuk/pgxdeepmind/mctxdeepmind/rlaxgoogle/brax