Coder Social home page Coder Social logo

sb3-tutorial's Introduction

SB3-tutorial

This repository contains code for the tutorial on using Stable Baselines 3 for creating custom environments and custom policies. A blog on the problem statement and the MDP formulation can be found at - https://nish-19.github.io/posts/2023/12/blog-post-6/.

Contents

  1. Installation
  2. Custom Environment
  3. PPO
  4. Custom Feature Extractor
  5. Custom Policy (LSTM Bilinear)

Installation

To install the python libraries using conda execute the following command:

conda env create -f environment.yml

Custom Environment

selection_env.py contains the code for our custom environment. The SelectionEnv class implements the custom environment and it extends from the OpenAI Gymnasium Environment gymnasium.Env

The method reset is used for resetting the environment and initializing the state. The method step executes an action in the current state and returns the next state, reward, and an indication whether the episode is completed or not.

PPO

python ppo.py

The function implement_PPO_algorithm implements the training and the testing procedure of the PPO algorithm.

Custom Feature Extractor

python custom_feature_ppo.py

CustomFeatureExtractor class implements a custom feature extraction layer containing 128 hidden units. RecurrentPolicy implements an LSTM over the features extracted from the state space using CustomFeatureExtractor class.

Custom Policy

python lstm_bilinear_policy.py

LstmBilinearPolicy implements a custom policy which uses an LSTM to extract features from the state representation using the LstmFeaturesExtractor class. The custom policy learns a projecition from the output of the LSTM to the space of the test cases represented using the test case embeddings (using a Transformer model). The methods _get_action_dist_from_latents and forward need to be overridden for implementing this feature.

sb3-tutorial's People

Contributors

nish-19 avatar

Watchers

 avatar  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.