Giter Site home page Giter Site logo

nikhilbarhate99 / hierarchical-actor-critic-hac-pytorch Goto Github PK

View Code? Open in Web Editor NEW
273.0 7.0 47.0 1.01 MB

PyTorch implementation of Hierarchical Actor Critic (HAC) for OpenAI gym environments

License: MIT License

Python 100.00%
pytorch reinforcement-learning reinforcement-learning-algorithms gym-environment hierarchical-reinforcement-learning actor-critic gym-environments openai-gym pytorch-implementation pytorch-rl

hierarchical-actor-critic-hac-pytorch's Introduction

Hierarchical-Actor-Critic-HAC-PyTorch

This is an implementation of the Hierarchical Actor Critic (HAC) algorithm described in the paper, Learning Multi-Level Hierarchies with Hindsight (ICLR 2019), in PyTorch for OpenAI gym environments. The algorithm learns to reach a goal state by dividing the task into short horizon intermediate goals (subgoals).

Usage

  • All the hyperparameters are contained in the train.py file.
  • To train a new network run train.py
  • To test a preTrained network run test.py
  • For a detailed explanation of offsets and bounds, refer to issue #2
  • For hyperparameters used for preTraining the pendulum policy refer to issue #3

Implementation Details

  • The code is implemented as described in the appendix section of the paper and the Official repository, i.e. without target networks and with bounded Q-values.
  • The Actor and Critic networks have 2 hidded layers of size 64.

Citing

Please use this bibtex if you want to cite this repository in your publications :

@misc{pytorch_hac,
    author = {Barhate, Nikhil},
    title = {PyTorch Implementation of Hierarchical Actor-Critic},
    year = {2021},
    publisher = {GitHub},
    journal = {GitHub repository},
    howpublished = {\url{https://github.com/nikhilbarhate99/Hierarchical-Actor-Critic-HAC-PyTorch}},
}

Requirements

Results

MountainCarContinuous-v0

(2 levels, H = 20, 200 episodes) (3 levels, H = 5, 200 episodes)
(2 levels, H = 20, 200 episodes)

References

hierarchical-actor-critic-hac-pytorch's People

Contributors

cun-bjy avatar nikhilbarhate99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hierarchical-actor-critic-hac-pytorch's Issues

Reg. Getting Gradient Loss values while testing

Hi I want to get the gradient loss with respect to input while I am testing. I tried the following in HAC.py after the next_state, rew, done, _ = env.step(action) line in the low level policy:

state = torch.FloatTensor(state).to(device)
action = torch.FloatTensor(action).to(device)
goal = torch.FloatTensor(goal).to(device)
criticval = self.HAC[0].critic(state, action, goal).detach()

with plans of computing a new target_Q in the moment to calculate loss and then gradient. However, I get the error Dimension out of range (expected to be in range of [-1, 0], but got 1). Any reason why this is happening?

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.