Code Monkey home page Code Monkey logo

rl_atari_games's Introduction

Reinforcement Learning with Atari Games

This repository focuses on exploring how Intrinsic Motivation (IM) effects Reinforcement Learning (RL) policy-based models. We use a Deep Q-Network (DQN) to simulate off-policy and Proximal Policy Optimization (PPO) as on-policy.

(Note) functionality for Rainbow Deep Q-Networks (RDQNs) is available but is not used during the study due to time constraints.

We focus on two IM methods: curiosity and empowerment, and evaluate their performance on three Atari games: Space Invaders, Q*bert, and Montezuma's Revenge. Our research aims to provide intuition on how IM methods affect these popular on-policy and off-policy agents.

Atari Games

Figure 1. Examples of each environment. From left to right: Space Invaders, Q*bert, and Montezuma's Revenge (Source: Gym Docs).

File Structure

The file structure for the artefact is outlined below.

+-- agents
|   +-- _agent.py
|   +-- dqn.py
|   +-- ppo.py
|   +-- rainbow.py
+-- core
|   +-- README.md
|   +-- buffer.py
|   +-- create.py
|   +-- enums.py
|   +-- env_details.py
|   +-- exceptions.py
|   +-- parameters.py
|   +-- template.yaml
+-- intrinsic
|   +-- _im_base.py
|   +-- controller.py
|   +-- empower_models.py
|   +-- model.py
|   +-- module.py
|   +-- parameters.py
+-- models
|   +-- _base.py
|   +-- actor_critic.py
|   +-- dueling.py
|   +-- linear.py
+-- tests
|   +-- test_buffer.py
|   +-- test_create.py
|   +-- test_dqn.py
|   +-- test_env_details.py
|   +-- test_helper.py
|   +-- test_intrisic.py
|   +-- test_logger.py
|   +-- test_models.py
|   +-- test_ppo.py
+-- utils
|   +-- dataloader.py
|   +-- helper.py
|   +-- init_devices.py
|   +-- logger.py
|   +-- model_utils.py
|   +-- plotter.py
|   +-- render.py
|   +-- validate.py
+-- .coverage
+-- .coveragerc
+-- LICENSE
+-- README.md
+-- main.py
+-- parameters.yaml
+-- requirements.txt
+-- demo.ipynb
  • \agents - contains the RL algorithm implementations
  • \core - core functionality of the artefact
  • \intrinsic - intrinsic motivation functionality
  • \models - neural network models for the agents
  • \tests - unit tests for the application
  • \utils - utility classes and functions that provide extra functionality

Dependencies

This project requires a Python 3.10 environment, which can be created with the following instructions:

  1. Install Visual Studio Build Tools (required for SuperSuit).

  2. Create (and activate) a new environment.

    • Linux or Mac
    conda create --name rlatari python=3.10
    source activate rlatari
    • Windows
    conda create --name rlatari python=3.10
    conda activate rlatari
  3. Clone the repository, navigate to the rl_atari_games/ folder and install the required dependencies.

    (Note) a requirements.txt file is accessible within this folder detailing a list of the required dependencies.

    git clone https://github.com/Achronus/rl_atari_games.git
    cd rl_atari_games
    conda install -c conda-forge jupyterlab
    conda install pytorch torchvision pytorch-cuda=11.7 -c pytorch -c nvidia
    pip install gymnasium[atari,accept-rom-license,other]
    pip install -r requirements.txt
  4. Create an IPython kernel for the rlatari environment.

    python -m ipykernel install --user --name rlatari --display-name "rlatari"
  5. Run the jupyter-lab command to start JupyterLab and access the Jupyter Notebook named rl_with_atari.ipynb, or run the main.py file.

    (Note) running the main.py file will train the models. It is advised to examine this file before running it.

References

The algorithms created in this repository have been inspired and adapted from the following developers:

Rainbow DQN -

PPO -

Intrinsic Motivation -

A special thanks to each of these developers for creating incredible work in the RL space. Please check out their original work using the links above.

rl_atari_games's People

Contributors

achronus avatar

Stargazers

 avatar

Watchers

 avatar  avatar

rl_atari_games's Issues

Error: Cannot batch space with type `<class 'gym.spaces.box.Box'>`. The space must be a valid `gymnasium.Space` instance.

Hello! Wonderful repository for playing with montezuma's revenge with an algorithm that works! :) :)

I am having a little bit of trouble getting it to run. After installing everything, I am running python main.py and get the following error: was wondering if you have seen this before?

Thanks so much in advance :)

/home/.conda/envs/rlatari/lib/python3.10/site-packages/gymnasium/vector/utils/spaces.py", line 49, in batch_space
raise ValueError(
ValueError: Cannot batch space with type <class 'gym.spaces.box.Box'>. The space must be a valid gymnasium.Space instance.

.

For further info, here is my pip list:
ale-py 0.8.0
asttokens 2.1.0
attrs 22.1.0
AutoROM 0.4.2
AutoROM.accept-rom-license 0.4.2
backcall 0.2.0
brotlipy 0.7.0
certifi 2022.9.24
cffi 1.15.1
charset-normalizer 2.0.4
click 8.1.3
cloudpickle 2.2.0
cryptography 38.0.1
cycler 0.11.0
decorator 4.4.2
executing 1.2.0
fonttools 4.38.0
gym 0.26.2
gym-notices 0.0.8
Gymnasium 0.26.3
gymnasium-notices 0.0.1
idna 3.4
imageio 2.22.4
imageio-ffmpeg 0.4.7
importlib-resources 5.10.0
iniconfig 1.1.1
ipython 8.4.0
jedi 0.18.1
kiwisolver 1.4.4
lz4 4.0.2
matplotlib 3.5.1
matplotlib-inline 0.1.6
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
moviepy 1.0.3
numpy 1.22.4
opencv-python 4.6.0.66
packaging 21.3
parso 0.8.3
PettingZoo 1.22.2
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.2.0
pip 22.2.2
pluggy 1.0.0
proglog 0.1.10
prompt-toolkit 3.0.32
ptyprocess 0.7.0
pure-eval 0.2.2
py 1.11.0
pycparser 2.21
pygame 2.1.2
Pygments 2.13.0
pymunk 6.2.1
pyOpenSSL 22.0.0
pyparsing 3.0.9
PySocks 1.7.1
pytest 7.1.2
python-dateutil 2.8.2
PyYAML 6.0
requests 2.28.1
setuptools 65.5.0
six 1.16.0
stack-data 0.6.1
SuperSuit 3.7.0
tinyscaler 1.2.5
tomli 2.0.1
torch 1.12.0
torchaudio 0.12.0
torchvision 0.13.0
tqdm 4.64.1
traitlets 5.5.0
typing_extensions 4.3.0
urllib3 1.26.12
wcwidth 0.2.5
wheel 0.37.1

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.