• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

State Representation Learning (SRL) zoo with PyTorch - Part of S-RL Toolbox

State Representation Learning Zoo with PyTorch (part of S-RL Toolbox)

A collection of State Representation Learning (SRL) methods for Reinforcement Learning, written using PyTorch.

SRL Zoo Documentation: https://srl-zoo.readthedocs.io/

S-RL Toolbox Documentation: https://s-rl-toolbox.readthedocs.io/

S-RL Toolbox Repository: https://github.com/araffin/robotics-rl-srl

Available methods:

  • Autoencoder (reconstruction loss)
  • Denoising Autoencoder (DAE)
  • Forward Dynamics model
  • Inverse Dynamics model
  • Reward prediction loss
  • Variational Autoencoder (VAE) and beta-VAE
  • SRL with Robotic Priors + extensions (stereovision, additional priors)
  • Supervised Learning
  • Principal Component Analysis (PCA)
  • Triplet Network (for stereovision only)
  • Combination and stacking of methods
  • Random Features
  • [experimental] Reward Prior, Episode-prior, Perceptual Similarity loss (DARLA), Mutual Information loss

Related papers:

Documentation

Documentation is available online: https://srl-zoo.readthedocs.io/

Installation

Please read the documentation for more details, we provide anaconda env files and docker images.

Learning a State Representation

To learn a state representation, you need to enforce constrains on the representation using one or more losses. For example, to train an autoencoder, you need to use a reconstruction loss. Most losses are not exclusive, that means you can combine them.

All losses are defined in losses/losses.py. The available losses are:

  • autoencoder: reconstruction loss, using current and next observation
  • denoising autoencoder (dae): same as for the auto-encoder, except that the model reconstruct inputs from noisy observations containing a random zero-pixel mask
  • vae: (beta)-VAE loss (reconstruction + kullback leiber divergence loss)
  • inverse: predict the action given current and next state
  • forward: predict the next state given current state and taken action
  • reward: predict the reward (positive or not) given current and next state
  • priors: robotic priors losses (see "Learning State Representations with Robotic Priors")
  • triplet: triplet loss for multi-cam setting (see Multiple Cameras section in the doc)

[Experimental]

  • reward-prior: Maximises the correlation between states and rewards (does not make sense for sparse reward)
  • episode-prior: Learn an episode-agnostic state space, thanks to a discriminator distinguishing states from same/different episodes
  • perceptual similarity loss (for VAE): Instead of the reconstruction loss in the beta-VAE loss, it uses the distance between the reconstructed input and real input in the embedding of a pre-trained DAE.
  • mutual information loss: Maximises the mutual information between states and rewards

All possible arguments can be display using python train.py --help. You can limit the training set size (--training-set-size argument), change the minibatch size (-bs), number of epochs (--epochs), ...

Datasets: Simulated Environments and Real Robots

Although the data can be generated easily using the RL repo in simulation (cf Generating Data), we provide datasets with a real baxter:

Examples

You can download an example dataset here.

Train an inverse model:

python train.py --data-folder data/path/to/dataset --losses inverse

Train an autoencoder:

python train.py --data-folder data/path/to/dataset --losses autoencoder

Combining an autoencoder with an inverse model is as easy as:

python train.py --data-folder data/path/to/dataset --losses autoencoder inverse

You can as well specify the weight of each loss:

python train.py --data-folder data/path/to/dataset --losses autoencoder:1 inverse:10

Please read the documentation for more examples.

Running Tests

Download the test datasets kuka_gym_test and kuka_gym_dual_test and put it in data/ folder.

./run_tests.sh

Troubleshooting

CUDA out of memory error

  1. python train.py --data-folder data/staticButtonSimplest
RuntimeError: cuda runtime error (2) : out of memory at /b/wheel/pytorch-src/torch/lib/THC/generic/THCStorage.cu:66

SOLUTION 1: Decrease the batch size, e.g. 32-64 in GPUs with little memory.

SOLUTION 2 Use simple 2-layers neural network model python train.py --data-folder data/staticButtonSimplest --model-type mlp

More Repositories

1

rl-baselines-zoo

A collection of 100+ pre-trained RL agents using Stable Baselines, training and hyperparameter optimization included.
Python
1,124
star
2

robotics-rl-srl

S-RL Toolbox: Reinforcement Learning (RL) and State Representation Learning (SRL) for Robotics
Python
609
star
3

rl-tutorial-jnrr19

Stable-Baselines tutorial for Journées Nationales de la Recherche en Robotique 2019
Jupyter Notebook
583
star
4

sbx

SBX: Stable Baselines Jax (SB3 + Jax)
Python
303
star
5

arduino-robust-serial

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.
C++
134
star
6

tools-for-robotic-rl-icra2022

Tutorial: Tools for Robotic Reinforcement Learning, Hands-on RL for Robotics with EAGER and Stable-Baselines3
HTML
91
star
7

rl-handson-rlvs21

Stable-Baselines3 (SB3) reinforcement learning tutorial for the Reinforcement Learning Virtual School 2021.
Jupyter Notebook
48
star
8

rlss23-dqn-tutorial

Deep Q-Network (DQN) and Fitted Q-Iteration (FQI) tutorial for RL Summer School 2023
Jupyter Notebook
47
star
9

aae-train-donkeycar

Code used to train an augmented auto-encoder (aka denoising auto-encoder with more augmentations) for the DonkeyCar simulator.
Python
43
star
10

rust-arduino-serial

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). This is the Rust implementation.
Rust
35
star
11

python-arduino-serial

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). This is the Python implementation.
Python
31
star
12

datasaurust

Blazingly fast implementation of the Datasaurus paper. Same Stats, Different Graphs.
Rust
19
star
13

cpp-arduino-serial

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). This is the C++ implementation.
C++
18
star
14

pybullet_envs_gymnasium

Port of pybullet envs to gymnasium
Python
13
star
15

graph-annotation-tool

A graph annotation tool using a flask server and javascript
HTML
12
star
16

advent-of-code-2022

advent-of-code-2022 with Rust, easy to read solutions
Rust
4
star
17

es-with-search-path

Implementation of the (μ/μ,λ)-Evolution Strategy (ES) with Search Path algorithm in C++
C
2
star
18

araffin.github.io

Personal Homepage
JavaScript
2
star
19

eagerx_quadruped

Python
1
star
20

custom-hugo-academic

HTML
1
star
21

her-experiments

Python
1
star