Coder Social home page Coder Social logo

cal's Introduction

CAL

Code accompanying the paper "Off-Policy Primal-Dual Safe Reinforcement Learning".

CAL

Installing Dependences

Safety-Gym

cd ./env/safety-gym/
pip install -e .

We follow the environment implementation in the CVPO repo to accelerate the training process. All the compared baselines in the paper are also evaluated on this environment. For further description about the environment implementation, please refer to Appendix B.2 in the CVPO paper.

MuJoCo

Refer to https://github.com/openai/mujoco-py.

Usage

Configurations for experiments, environments, and algorithmic components as well as hyperparameters can be found in /arguments.py.

Training

For Safety-Gym tasks:

python main.py --env_name Safexp-PointButton1-v0 --num_epoch 500

For MuJoCo tasks:

python main.py --env_name Ant-v3 --num_epoch 300 --c 100 --qc_ens_size 8

Algorithmic configurations

Safety-Gym

We adopt the same hyperparameter setting across all Safety-Gym tasks tested in our work (PointButton1, PointButton2, CarButton1, CarButton2, PointPush1), which is the default setting in /arguments.py.

MuJoCo

The configurations different from the default setting are as follows:

  • The conservatism parameter $k$ (--k in /arguments.py) is 0. for Humanoid.

  • The convexity parameter $c$ (--c) is 100 for Ant, and 1000 for HalfCheetah and Humanoid.

  • The replay ratio (--num_train_repeat) is 20 for HalfCheetah.

  • The ensemble size $E$ of the safety critic (--qc_ens_size) is 8 for all MuJoCo tasks (may be smaller, like 4, for Hopper and Humanoid).

    In my test runs, thanks to the batch matrix multiplication function provided by PyTorch, the size of the ensemble does not significantly affect the running speed.

  • The option --intrgt_max is True for Humanoid.

    While in CAL conservatism is originally incorporated in policy optimization, for the Humanoid task we found it more effective to instead incorporate conservatism into $Q_c$ learning.

Logging

The codebase contains wandb as a visualization tool for experimental management. The user can initiate a wandb experiment by adding --use_wandb in the command above and specifying the wandb user account by --user_name [your account].

Reference

@article{wu2024off,
  title={Off-Policy Primal-Dual Safe Reinforcement Learning},
  author={Wu, Zifan and Tang, Bo and Lin, Qian and Yu, Chao and Mao, Shangqin and Xie, Qianlong and Wang, Xingxing and Wang, Dong},
  journal={arXiv preprint arXiv:2401.14758},
  year={2024}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.