applied-reinforcement-learning icon indicating copy to clipboard operation
applied-reinforcement-learning copied to clipboard

Reinforcement Learning and Decision Making tutorials explained at an intuitive level and with Jupyter Notebooks

Applied Reinforcement Learning

I've been studying reinforcement learning and decision-making for a couple of years now. One of the most difficult things that I've encountered is not necessarily related to the concepts but how these concepts have been explained. To me, learning occurs when one is able to make a connection with the concepts being taught. For this, often an intuitive explanation is required, and likely a hands-on approach helps build that kind of understanding.

My goal for this repository is to create, with the community, a resource that would help newcomers understand reinforcement learning in an intuitive way. Consider what you see here my initial attempt to teach some of these concepts as plain and simple as I can possibly explain them.

If you'd like to collaborate, whether a typo, or an entire addition to the text, maybe a fix to a notebook or a whole new notebook, please feel free to send your issue and/or pull request to make things better. As long as your pull request aligns with the goal of the repository, it is very likely we will merge. I'm not the best teacher, or reinforcement learning researcher, but I do believe we can make reinforcement learning and decision-making easy for anyone to understand. Well, at least easier.

Table of Contents

  • Notebooks Installation
    • Install git
    • Install Docker
    • Run Notebooks
      • TL;DR version
      • A little more detailed version:
        • Open the Notebooks in your browser:
        • Open TensorBoard at the following address:
    • Docker Tips
  • Part I: Introduction
    • 1. Introduction to Decision-Making
      • 1.1 Decision-Making
      • 1.2 Further Reading
  • Part II: Reinforcement Learning and Decision-Making
    • 2. Sequential Decisions
      • 2.1 Modeling Decision-Making Problems
      • 2.2 Solutions Representation
      • 2.3 Simple Sequential Problem
      • 2.4 Slightly more complex problems
      • 2.5 Evaluating solutions
      • 2.6 Improving on solutions
      • 2.7 Finding Optimal solutions
      • 2.8 Improving on Policy Iteration
      • 2.9 Exercises
      • 2.10 Further Reading
    • 3. Deterministic and Stochastic Actions
      • 3.1 We can't perfectly control the world
      • 3.2 Dealing with stochasticity
      • 3.3 Exercises
      • 3.4 Further Reading
    • 4. Known and Unknown Environments
      • 4.1 What if we don't have a model of the environment?
      • 4.2 The need to explore
      • 4.3 What to learn?
      • 4.4 What to do with what we learn?
      • 4.5 Adding small randomness to your actions
      • 4.6 Exercises
      • 4.7 Further Reading
  • Part III: Decision-Making in Hard Problems
    • 5. Discrete and Continuous States
      • 5.1 Too large to hold in memory
      • 5.2 Discretization of state space
      • 5.3 Use of function approximation
      • 5.4 Exercises
      • 5.5 Further Reading
    • 6. Discrete and Continuous Actions
      • 6.1 Continuous action space
      • 6.2 Discretizition of action space
      • 6.3 Use of function approximation
      • 6.4 Searching for the policy
      • 6.5 Exercises
      • 6.6 Further Reading
    • 7. Observable and Partially-Observable States
      • 7.1 Is what we see what it is?
      • 7.2 State Estimation
      • 7.3 Control in Partially-Observable Environments
      • 7.4 Further Reading
  • Part IV: Multiple Decision-Making Agents
    • 8. Single and Multiple Agents
      • 8.1 Agents with same objectives
      • 8.2 What when other agents are at play?
      • 8.3 Further Reading
    • 9. Cooperative and Adversarial Agents
      • 9.1 Agents with conflicting objectives
      • 9.2 Teams of agents with conflicting objectives
      • 9.3 Further Reading
  • Part V: Human Decision-Making and Beyond
    • 10. Decision-Making and Humans
      • 10.1 Similarities between methods discussed and humans
      • 10.2 Differences between methods discussed and humans
      • 10.3 Further Reading
    • 11. Conclusion
    • 12. Recommended Books
    • 12. Recommended Courses

Notebooks Installation

This repository contains Jupyter Notebooks to follow along with the lectures. However, there are several packages and applications that need to be installed. To make things easier on you, I took a little longer time to setup a reproducible environment that you can use to follow along.

Install git

Follow the instructions at (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

Install Docker

Follow the instructions at (https://docs.docker.com/engine/getstarted/step_one/#step-2-install-docker)

Run Notebooks

TL;DR version

  1. git clone [email protected]:mimoralea/applied-reinforcement-learning.git && cd applied-reinforcement-learning
  2. docker pull mimoralea/openai-gym:v1
  3. docker run -it --rm -p 8888:8888 -p 6006:6006 -v $PWD/notebooks/:/mnt/notebooks/ mimoralea/openai-gym:v1

A little more detailed version:

  1. Clone the repository to a desired location (E.g. git clone [email protected]:mimoralea/applied-reinforcement-learning.git ~/Projects/applied-reinforcement-learning)
  2. Enter into the repository directory (E.g. cd ~/Projects/applied-reinforcement-learning)
  3. Either Build yourself or Pull the already built Docker container:
    3.1. To build it use the following command: docker build -t mimoralea/openai-gym:v1 .
    3.2. To pull it from Docker hub use: docker pull mimoralea/openai-gym:v1
  4. Run the container: docker run -it --rm -p 8888:8888 -p 6006:6006 -v $PWD/notebooks/:/mnt/notebooks/ mimoralea/openai-gym:v1

Open the Notebooks in your browser:

  • http://localhost:8888 (or follow the link that came out of the run command about which will include the token)

Open TensorBoard at the following address:

  • http://localhost:6006

This will help you visualize the Neural Network in the lessons with function approximation.

Docker Tips

  • If you'd like to access a bash session of a running container do:
    ** docker ps # will show you currently running containers -- note the id of the container you are trying to access
    ** docker exec --user root -it c3fbc82f1b49 /bin/bash # in this case c3fbc82f1b49 is the id
  • If you'd like to start a new container instance straight into bash (without running Jupyter or TensorBoard)
    ** docker run -it --rm mimoralea/openai-gym:v1 /bin/bash # this will run the bash session as the Notebook user
    ** docker run --user root -e GRANT_SUDO=yes -it --rm mimoralea/openai-gym:v1 /bin/bash # this will run the bash session as root