Giter Site home page Giter Site logo

zjlab-ammi / hs-omrl Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 128 KB

Python code to implement hard sampling based task representation learning for robust offline meta RL

Home Page: https://arxiv.org/abs/2304.00354

Python 100.00%
imbalanced-learning importance-sampling meta-reinforcement-learning offline-reinforcement-learning reinforcement-learning-algorithms

hs-omrl's Introduction

This is python code to implement the algorithm reported in the following paper

Abstract

Offline meta reinforcement learning (OMRL) aims to learn transferrable knowledge from offline datasets to facilitate the learning process for new target tasks. Context-based RL employs a context encoder to rapidly adapt the agent to new tasks by inferring about the task representation, and then adjusting the acting policy based on the inferred task representation. Here we consider context-based OMRL, in particular, the issue of task representation learning for OMRL. We empirically demonstrate that the context encoder trained on offline datasets could suffer from distribution shift between the contexts used for training and testing. To tackle this issue, we propose a hard sampling based strategy for learning a robust task context encoder. Experimental results, based on distinct continuous control tasks, demonstrate that the utilization of our technique results in more robust task representations and better testing performance in terms of accumulated returns, compared with baseline methods.

Experiments

We demonstrate with PointRobotGoal environment. For other environments, change the argument --env-type according to the table:

Environment Argument
Point-Robot point_goal
Half-Cheetah-Vel cheetah_vel
Ant-Dir ant_dir
Hopper-Param hopper_param
Walker-Param walker_param

Data Collection

Copy the following code into a shell script, and run the script.

python train_data_collection.py --env-type point_goal --save-models 1 --log-tensorboard 1 --seed $seed

Train the Task Encoder

python train_contrastive.py --env-type point_goal --layer-type SupCL --contrastive-loss combine

To train with different sampling strategies, replace combine with hard_neg, hard_pos or easy.

Offline Meta-RL

python train_offpolicy_with_trained_encoder.py --env-type point_goal  --encoder-model-path PATH_TO_MODEL

Citation

If you find this code useful, please kindly cite

@article{zhao2023on,
  title={On Context Distribution Shift in Task Representation Learning for Offline Meta RL},
  author={Zhao, Chenyang; Zhou, Zihao and Liu, Bin},
  journal={arXiv preprint arXiv:2304.00354},
  year={2023}
}

Acknowledgement

This code is based on CORRO.

hs-omrl's People

Contributors

czhaozjlab avatar robinlau1981 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

robinlau1981

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.