Template code for reinforcement learning assignments.
Install requirements:
conda create -n rl_assignments python=3.8
conda activate rl_assignments
pip install -r requirements.txt
and it should be good to go.
To train a policy, run the following command:
python run.py --env_config data/envs/dm_cheetah.yaml --agent_config a2/dm_cheetah_cem_agent.yaml --mode train --log_file output/log.txt --out_model_file output/model.pt --visualize --num_workers 1
--env_configspecifies the configuration file for the environment.--agent_configspecifies configuration file for the agent.--visualizeenables visualization. Rendering should be disabled for faster training.--log_filespecifies the output log file, which will keep track of statistics during training.--out_model_filespecifies the output model file, which contains the model parameters.--num_workersspecifies the number of worker processes used to parallelize training.
To load a trained model, run the following command:
python run.py --env_config data/envs/dm_cheetah_env.yaml --agent_config a2/dm_cheetah_cem_agent.yaml --mode test --model_file [path to model.pt] --visualize --num_workers 1
--model_filespecifies the.ptfile that contains parameters for the trained model. Pretrained models are available indata/models/.
During training, a tensorboard events file will be saved the same output directory as the log file. The log can be viewed with:
tensorboard --logdir=output/ --port=6006 --bind_all
The output log .txt file can also be plotted using the plotting script in tools/plot_log/plot_log.py.