Skip to content

Deep Q-Network implementation using PyTorch to solve a 2D navigation + rewards collection task.

Notifications You must be signed in to change notification settings

JunShern/dqn-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dqn-navigation

This repository contains my submission for Project 1: Navigation of the Udacity Deep Reinforcement Learning Nanodegree.

Project Details

The assignment is to train an agent that solves the Unity ML-Agents "Banana" environment.

The solution implements a Deep Q-Network based on [1] to solve the environment. For implementation and algorithm details, please see Report.md.

trained_agent

The trained agent is able to effectively navigate the environment, collecting yellow bananas (positive rewards) while avoiding blue bananas (negative rewards).

Environment

(The below description is replicated from the udacity/deep-reinforcement-learning repository.)

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, your agent must get an average score of +13 over 100 consecutive episodes.

Getting started

Prerequisites

  • Python >= 3.6
  • A GPU is NOT required; the agent is simple enough to be trained on a standard CPU 🎉

Installation

  1. Clone the repository.
git clone https://github.com/JunShern/dqn-navigation.git
  1. Create a virtual environment to manage your dependencies.
cd dqn-navigation/
python3 -m venv .venv
source .venv/bin/activate # Activate the virtualenv
  1. Install python dependencies
cd dqn-navigation/python
pip install .
  1. Add your virtual environment to jupyter's kernels.
python -m ipykernel install --user --name .venv --display-name "deeprl"
  1. Download the Banana environment from one of the links below:

    Place the file in the root of this repository, and unzip (or decompress) the file.

Instructions

The project is intended to be run from Navigation.ipynb.

  1. Run jupyter-notebook
cd dqn-navigation/
source .venv/bin/activate # Activate the virtualenv
jupyter-notebook
  1. Open Navigation.ipynb.
  2. Follow the instructions in the notebook.

References

  • [1] Mnih, Volodymyr, et al. "Human-level control through deep reinforcement learning." nature 518.7540 (2015): 529-533.

About

Deep Q-Network implementation using PyTorch to solve a 2D navigation + rewards collection task.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published