Giter VIP home page Giter VIP logo

sb3_practice's Introduction

SB3_practice

Long-term collection of RL practice in the framework of Stable Baselines 3. I will make sure that each example is not the same, each has different processing details (except "hello world" enviroments: Cartpole and Lunarlander).

Lastest version of SB3: Installation.

Experimental features based on SB3: SB3 Contrib.

Anything about Gym enviroment: Gym Documentation.

Cartpole by PPO

Cartpole is a classical Gym enviroment (for details see here).

See codes here.

Log

Episode length Episode reward

Lunarlander by PPO

Lunarlander is a classical Gym enviroment, aiming at rocket trajectory optimization (for details see here).

See codes here.

Log

Episode length Episode reward

Gridworld by PPO

Gridworld is modified from a custom Gym enviroment (for details see here), where an episode ends when the agent reaches the destination.

See codes here.

Video

Random step PPO agent

Maze by maskable PPO

Maze is a 2d gridworld-like enviroment.

  • Masking invalid actions greatly speeds up the training process of neural network.
  • 1d observation is applied though it's natural to use a image-like observation. The reason is, SB3 CnnPolicy require image data to have a minimum size of 36x36. Lukily, a flattened observation still works well.

See codes here.

Log

Episode length Episode reward

Video

Random step PPO agent

Maze by maskable PPO with Data Augment

Can the agent make correct decisions if the evaluation environment is different from the training environment? Applying data augment in training may help. In this case, the evaluation enviroment is a symmetric equivalent transformation of the training enviroment. An easy idea is generating equivalent batch datas based on the original batch data.

In order to achieve this goal, I build a custom callback and handle the rollout buffer data directly (See how to customize callback here) . We need to handle 9 kinds of data:

  • Expand observations, actions and action_masks.
  • Share episode_starts and rewards.
  • Recompute values and log_probs.
  • Recompute returns and advantages.

See codes here.

Video

Training enviroment Evaluation enviroment

Something interesting is, while the agent performed perfectly in the training environment, it got stuck in the evaluation environment. KL divergence explains this, large value of approx_kl seems to indicate that the network is not fully fitted:

total_steps = 8e4 total_steps = 15e4
approx_kl = 2.1942 approx_kl = 0.1253

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.