RL Algorithms with examples in Python / Pytorch / Unity ML agents

Overview

Reinforcement Learning Project

This project was created to make it easier to get started with Reinforcement Learning. It now contains:

Getting Started

Install Basic Dependencies

To set up your python environment to run the code in the notebooks, follow the instructions below.

  • If you're on Windows I recommend installing Miniforge. It's a minimal installer for Conda. I also recommend using the Mamba package manager instead of Conda. It works almost the same as Conda, but only faster. There's a cheatsheet of Conda commands which also work in Mamba. To install Mamba, use this command:
conda install mamba -n base -c conda-forge 
  • Create (and activate) a new environment with Python 3.6 or later. I recommend using Python 3.9:

    • Linux or Mac:
    mamba create --name rl39 python=3.9 numpy
    source activate rl39
    • Windows:
    mamba create --name rl39 python=3.9 numpy
    activate rl39
  • Install PyTorch by following instructions on Pytorch.org. For example, to install PyTorch on Windows with GPU support, use this command:

mamba install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
  • Install additional packages:
mamba install jupyter notebook matplotlib
python -m ipykernel install --user --name rl39 --display-name "rl39"
  • Change the kernel to match the rl39 environment by using the drop-down menu Kernel -> Change kernel inside Jupyter Notebook.

Install Unity Machine Learning Agents

Note: In order to run the notebooks on Windows, it's not necessary to install the Unity Editor, because I have provided the standalone executables of the environments for you.

Unity ML Agents is the software that we use for the environments. The agents that we create in Python can interact with these environments. Unity ML Agents consists of several parts:

  • The Unity Editor is used for creating environments. To install:

    • Install Unity Hub.
    • Install the latest version of Unity by clicking on the green button Unity Hub on the download page.

    To start the Unity editor you must first have a project:

    • Start the Unity Hub.
    • Click on "Projects"
    • Create a new dummy project.
    • Click on the project you've just added in the Unity Hub. The Unity Editor should start now.
  • The Unity ML-Agents Toolkit. Download the latest release of the source code or use the Git command: git clone --branch release_18 https://github.com/Unity-Technologies/ml-agents.git.

  • The Unity ML Agents package is used inside the Unity Editor. Please read the instructions for installation.

  • The mlagents Python package is used as a bridge between Python and the Unity editor (or standalone executable). To install, use this command: python -m pip install mlagents==0.27.0. Please note that there's no conda package available for this.

Install an IDE for Python

For Windows, I would recommend using PyCharm (my choice), or Visual Studio Code. Inside those IDEs you can use the Conda environment you have just created.

Creating a custom Unity executable

Load the examples project

The Unity ML-Agents Toolkit contains several example environments. Here we will load them all inside the Unity editor:

  • Start the Unity Hub.
  • Click on "Projects"
  • Add a project by navigating to the Project folder inside the toolkit.
  • Click on the project you've just added in the Unity Hub. The Unity Editor should start now.

Create a 3D Ball executable

The 3D Ball example contains 12 environments in one, but this doesn't work very well in the Python API. The main problem is that there's no way to reset each environment individually. Therefore, we will remove the other 11 environments in the editor:

  • Load the 3D Ball scene, by going to the project window and navigating to Examples -> 3DBall -> Scenes-> 3DBall
  • In the Hierarchy window select the other 11 3DBall objects and delete them, so that only the 3DBall object remains.

Next, we will build the executable:

  • Go to File -> Build Settings
  • In the Build Settings window, click Build
  • Navigate to notebooks folder and add 3DBall to the folder name that is used for the build.

Instructions for running the notebooks

  1. Download the Unity executables for Windows. In case you're not on Windows, you have to build the executables yourself by following the instructions above.
  2. Place the Unity executable folders in the same folder as the notebooks.
  3. Load a notebook with Jupyter notebook. (The command to start Jupyter notebook is jupyter notebook)
  4. Follow further instructions in the notebook.
You might also like...
An example project demonstrating how the Autonomous Learning Library can be used to build new reinforcement learning agents.
An example project demonstrating how the Autonomous Learning Library can be used to build new reinforcement learning agents.

About This repository shows how Autonomous Learning Library can be used to build new reinforcement learning agents. In particular, it contains a model

​TextWorld is a sandbox learning environment for the training and evaluation of reinforcement learning (RL) agents on text-based games.

TextWorld A text-based game generator and extensible sandbox learning environment for training and testing reinforcement learning (RL) agents. Also ch

Pacman-AI - AI project designed by UC Berkeley. Designed reflex and minimax agents for the game Pacman.
Pacman-AI - AI project designed by UC Berkeley. Designed reflex and minimax agents for the game Pacman.

Pacman AI Jussi Doherty CAP 4601 - Introduction to Artificial Intelligence - Fall 2020 Python version 3.0+ Source of this project This repo contains a

Scripts of Machine Learning Algorithms from Scratch. Implementations of machine learning models and algorithms using nothing but NumPy with a focus on accessibility. Aims to cover everything from basic to advance.
Scripts of Machine Learning Algorithms from Scratch. Implementations of machine learning models and algorithms using nothing but NumPy with a focus on accessibility. Aims to cover everything from basic to advance.

Algo-ScriptML Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The goal of this project is not t

Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.
Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.

PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers 1 Using Colab Please notic

PyTorch implementation of Advantage async actor-critic Algorithms (A3C) in PyTorch
PyTorch implementation of Advantage async actor-critic Algorithms (A3C) in PyTorch

Advantage async actor-critic Algorithms (A3C) in PyTorch @inproceedings{mnih2016asynchronous, title={Asynchronous methods for deep reinforcement lea

TensorRT examples (Jetson, Python/C++)(object detection)
TensorRT examples (Jetson, Python/C++)(object detection)

TensorRT examples (Jetson, Python/C++)(object detection)

Hi Guys, here I am providing examples, which will help you in Lerarning Python

LearningPython Hi guys, here I am trying to include as many practice examples of Python Language, as i Myself learn, and hope these will help you in t

Releases(v1.0.0)
Owner
Rogier Wachters
Rogier Wachters
This is an official implementation for "ResT: An Efficient Transformer for Visual Recognition".

ResT By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software Technology at Nanjing University] This repo is the official implement

zhql 222 Dec 13, 2022
1st-in-MICCAI2020-CPM - Combined Radiology and Pathology Classification

Combined Radiology and Pathology Classification MICCAI 2020 Combined Radiology a

22 Dec 08, 2022
Illuminated3D This project participates in the Nasa Space Apps Challenge 2021.

Illuminated3D This project participates in the Nasa Space Apps Challenge 2021.

Eleftheriadis Emmanouil 1 Oct 09, 2021
Train DeepLab for Semantic Image Segmentation

Train DeepLab for Semantic Image Segmentation Martin Kersner, [email protected]

Martin Kersner 172 Dec 14, 2022
Face Alignment using python

Face Alignment Face Alignment using python Input Image Aligned Face Aligned Face Aligned Face Input Image Aligned Face Input Image Aligned Face Instal

Sajjad Aemmi 28 Nov 23, 2022
Docker containers of baseline agents for the Crafter environment

Crafter Baselines This repository contains Docker containers for running various baselines on the Crafter environment. Reward Agents DreamerV2 based o

Danijar Hafner 17 Sep 25, 2022
Pseudo lidar - (CVPR 2019) Pseudo-LiDAR from Visual Depth Estimation: Bridging the Gap in 3D Object Detection for Autonomous Driving

Pseudo-LiDAR from Visual Depth Estimation: Bridging the Gap in 3D Object Detection for Autonomous Driving This paper has been accpeted by Conference o

Yan Wang 881 Dec 27, 2022
Multi-Horizon-Forecasting-for-Limit-Order-Books

Multi-Horizon-Forecasting-for-Limit-Order-Books This jupyter notebook is used to demonstrate our work, Multi-Horizon Forecasting for Limit Order Books

Zihao Zhang 116 Dec 23, 2022
Medical Insurance Cost Prediction using Machine earning

Medical-Insurance-Cost-Prediction-using-Machine-learning - Here in this project, I will use regression analysis to predict medical insurance cost for people in different regions, and based on several

1 Dec 27, 2021
This is the code repository for the paper A hierarchical semantic segmentation framework for computer-vision-based bridge column damage detection

Bridge-damage-segmentation This is the code repository for the paper A hierarchical semantic segmentation framework for computer-vision-based bridge c

Jingxiao Liu 5 Dec 07, 2022
Neural Surface Maps

Neural Surface Maps Official implementation of Neural Surface Maps - Luca Morreale, Noam Aigerman, Vladimir Kim, Niloy J. Mitra [Paper] [Project Page]

Luca Morreale 49 Dec 13, 2022
TriMap: Large-scale Dimensionality Reduction Using Triplets

TriMap TriMap is a dimensionality reduction method that uses triplet constraints to form a low-dimensional embedding of a set of points. The triplet c

Ehsan Amid 235 Dec 24, 2022
The PyTorch re-implement of a 3D CNN Tracker to extract coronary artery centerlines with state-of-the-art (SOTA) performance. (paper: 'Coronary artery centerline extraction in cardiac CT angiography using a CNN-based orientation classifier')

The PyTorch re-implement of a 3D CNN Tracker to extract coronary artery centerlines with state-of-the-art (SOTA) performance. (paper: 'Coronary artery centerline extraction in cardiac CT angiography

James 135 Dec 23, 2022
Anagram Generator in Python

Anagrams Generator This is a program for computing multiword anagrams. It makes no effort to come up with sentences that make sense; it only finds ana

Day Fundora 5 Nov 17, 2022
MLP-Numpy - A simple modular implementation of Multi Layer Perceptron in pure Numpy.

MLP-Numpy A simple modular implementation of Multi Layer Perceptron in pure Numpy. I used the Iris dataset from scikit-learn library for the experimen

Soroush Omranpour 1 Jan 01, 2022
[IJCAI-2021] A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation"

DataFree A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation" Authors: Gongfa

ZJU-VIPA 47 Jan 09, 2023
Compositional and Parameter-Efficient Representations for Large Knowledge Graphs

NodePiece - Compositional and Parameter-Efficient Representations for Large Knowledge Graphs NodePiece is a "tokenizer" for reducing entity vocabulary

Michael Galkin 107 Jan 04, 2023
Machine Translation Implement By Bi-GRU And Transformer

Seq2Seq Translation Implement By Bidirectional GRU And Transformer In Pytorch Before You Run The Code You should download the data through the link be

He Wang 2 Oct 27, 2021
Advancing Self-supervised Monocular Depth Learning with Sparse LiDAR

Official implementation for paper "Advancing Self-supervised Monocular Depth Learning with Sparse LiDAR"

Ziyue Feng 72 Dec 09, 2022
More than a hundred strange attractors

dysts Analyze more than a hundred chaotic systems. Basic Usage Import a model and run a simulation with default initial conditions and parameter value

William Gilpin 185 Dec 23, 2022