Git Product home page Git Product logo

grads's Introduction

Gradient Shaping for Multi-constraint Safe Reinforcement Learning

Implementation code for L4DC 2024 paper https://arxiv.org/html/2312.15127.

Installation

This repo can be installed on Ubuntu 18.04. Create a conda environment (recommended Python 3.8), then install PyTorch based on your platform. Then run

cd GradS
pip install -e .

To use the Bullet-Safety-Gym environment, please use the repo in this folder which supports gym>=0.26.0 API and multiple safety constraints:

cd ../Bullet-Safety-Gym
pip install -e .

Structure

The structure of this repo is as follows:

├── GradS  # implementation of MC safe RL algorithms
│   ├── fsrl
│   │   ├── data # data collector
│   │   ├── agent # safe RL agent
│   │   ├── policy # safe RL policy
│   │   ├── trainer # safe RL trainer
│   │   ├── config # training config
│   │   ├── utils # logger and network 
│   ├── examples # training files
├── Bullet-Safety-Gym  # training envs

Usage

By running the following code in the terminal, you will be able to test the GradS with PPO-Lag as a base algorithm.

cd GradS/examples
python train_ppo_agent.py --seed [SS] --short_task [TT]

where SS specifies the random seed and short_task specifies the task. You may choose it from {"BC-v2", "CC-v2", "DC-v2", "BC-v3", "CC-v3", "DC-v3"}. By default, the seed is set to be 10, and cost limits for different constraints in each task can be found in the file "GradS/fsrl/config/ppol_cfg.py". After running this command, you can check the training stats for the "BC-v3" task in the wandb logger. Under the tabs "train" and "test", we provide the "sub_cost_0", "sub_cost_1", and "sub_cost_2", which represents the high-speed cost, boundary cost, and low-speed cost, respectively.

Acknowledge

This repo is partly based on Tianshou and FSRL.

grads's People

Contributors

yihangyao avatar

Watchers

 avatar

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.