Skip to content

An implementation of Deep Q-Learning Network for solving a Unity environment that can navigate and collect bananas in a large, square world.

Notifications You must be signed in to change notification settings

eljandoubi/DQN-for-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DQN-Navigation

This repository contains material from Udacity's Value-based Methods github.

Introduction

For this project, we train an agent to navigate (and collect bananas!) in a large, square world.

Trained Agent

A reward of +1 is provided for collecting a yellow banana, and a reward of -1 is provided for collecting a blue banana. Thus, the goal of your agent is to collect as many yellow bananas as possible while avoiding blue bananas.

The state space has 37 dimensions and contains the agent's velocity, along with ray-based perception of objects around agent's forward direction. Given this information, the agent has to learn how to best select actions. Four discrete actions are available, corresponding to:

  • 0 - move forward.
  • 1 - move backward.
  • 2 - turn left.
  • 3 - turn right.

The task is episodic, and in order to solve the environment, an agent must get an average score of +13 over 100 consecutive episodes.

For the Optional Challenge: Learning from Pixels

This environment is almost identical to the project environment, where the only difference is that the state is an 84 x 84 RGB image, corresponding to the agent's first-person view of the environment.

Dependencies

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

  1. Create (and activate) a new environment with Python 3.9.

    • Linux or Mac:
    conda create --name drlnd 
    source activate drlnd
    • Windows:
    conda create --name drlnd 
    activate drlnd
  2. Follow the instructions in Pytorch web page to install pytorch and its dependencies (PIL, numpy,...). For Windows and cuda 11.6

    conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
  3. Follow the instructions in this repository to perform a minimal install of OpenAI gym.

    • Install the box2d environment group by following the instructions here.
    pip install gym[box2d]
  4. Follow the instructions in Navigation to get the environment.

  5. Clone the repository, and navigate to the python/ folder. Then, install several dependencies.

git clone https://github.com/eljandoubi/DQN-Navigation.git
cd DQN-Navigation/python
pip install .
  1. Create an IPython kernel for the drlnd environment.
python -m ipykernel install --user --name drlnd --display-name "drlnd"
  1. Before running code in a notebook, change the kernel to match the drlnd environment by using the drop-down Kernel menu.

Kernel

Training and inference

You can train and/or inference Navigation (Pixels) environment:

First, go to p1_navigation/.

Then, run the training and/or inference cell of Deep_Q_Network_Navigation(_Pixels).ipynb.

The pre-trained model with the highest score is stored in Navigation_(Pixels_)checkpoint.

Implementation and Resultats

The implementation and resultats are discussed in the report.

About

An implementation of Deep Q-Learning Network for solving a Unity environment that can navigate and collect bananas in a large, square world.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published