GithubHelp home page GithubHelp logo

stayyule / udacity-drl-p1-dqn Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3.37 MB

This is a reinforcement learning project in unity ml-agents environment. An agent is trained to navigate (and collect bananas!) in a large, square world. The Agent is a DQN written in pytorch.

Jupyter Notebook 40.65% Python 21.51% HTML 37.84%
unity-ml-agents udacity-nanodegree reinforcement-learning pytorch-cnn

udacity-drl-p1-dqn's Introduction

Platform Python

Reinforcement-learning-unity-banana

Introduction

This is a reinforcement learning project in unity ml-agents environment. An agent is trained 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.

This repository is also a project of Udacity's Deep Reinforcement Learning Nanodegree program, check out for more instructions there.

Installation

  1. Download the environment from one of the links below. You need only select the environment that matches your operating system:

  2. Place the file under root folder of the repository, and unzip (or decompress) the file.

  3. Install Anaconda

  4. Run code in anaconda prompt to setup python environment

conda env create -f environment.yaml

Run the exercise

  • Activate ml-agents environment with code
activate ml-agents
  • There're several instructions notebook under /report. Open Navigation.ipynb to get started with training agent step by step! Open Report.ipynb to read details for design and implementations. To open these instructions, get to repository folder and type in anaconda prompt:
jupyter notebook
  • You can simply run /dqn/navigation.py to train.
python navigation.py

A Unity window will pop up and show the process of training. The score will prompt in console and trained model will be saved.

Network and Hyperparameters

Neural network has an input size of 37 and hidden layers size of 64 and output size of 4.

nn agent_network

Other hyperparameters:

BUFFER_SIZE = int(1e5)  # replay buffer size
BATCH_SIZE = 64         # minibatch size
GAMMA = 0.99            # discount factor
TAU = 1e-3              # for soft update of target parameters
LR = 5e-4               # learning rate 
UPDATE_EVERY = 4        # how often to update the network

Result

This agent collect an average of 13+ in 100 episodes and finish it in 600 epsiodes.

Episode 100 Average Score: 0.97

Episode 200 Average Score: 4.52

Episode 300 Average Score: 8.18

Episode 400 Average Score: 10.72

Episode 500 Average Score: 12.82

Episode 600 Average Score: 14.44

result

udacity-drl-p1-dqn's People

Contributors

dependabot[bot] avatar stayyule avatar

Watchers

 avatar  avatar

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.