Giter Club home page Giter Club logo

learning-to-drive-in-a-day's Introduction

learning-to-drive-in-a-day

DISCLAIMER: This repo is a boilerplate for the approach described in paper. It works in general, but not stable enough to reproduce good policy in 100% cases. I recommend to play with pretrained VAE to get quicker results.

Video with real RC car.

Code that implements approach similar to described in "Learning to Drive in a Day" paper.

Missing parts:

  • Prioritized Experience Replay in DDPG. Right now we randomly sample.
  • Params well tuning to drive more smoothly.

Quick start

NOTE: Assuming Intel Graphics (/dev/dri) present.

Download compiled Donkey Car simulator (source) into $HOME/sim directory.

Run training.

docker build -t learning-to-drive-in-a-day .
./run-in-docker.sh

Run test with the same command (script run test if there are trained models ddpg.pkl and vae.json).

./run-in-docker.sh

Under the hood

Script does the following:

  • Initialize Donkey OpenAI gym environment.
  • Initialize VAE controller with random weights.
  • If no pretrained models found, run in train mode. Otherwise just load weights from files and run test.
  • Initialize DDPG controller.
  • Learning function will collect the data by running 10 episodes w/o DDPG optimization, then after every episode DDPG optimization happens. VAE optimized after every episode.
  • After 3000 steps training will be finished and weights params will be saved to files.

Troubleshooting

Disable VAE optimization

Implementation is still very very raw and needs fine tuning, so to get quick results i recommend to run full session and then reuse vae.json (or use pretrained) in new training session by adding vae.load(PATH_MODEL_VAE) before ddpg.learn and commenting out vae.optimize() in ddpg_with_vae.py. This will allow to train DDPG very quickly even on CPU machine.

Visualize what car sees

Following code can be used to decode VAE's Z latent vector and save to image.

arr = vae.decode(obs)
arr = np.round(arr).astype(np.uint8)
arr = arr.reshape(80, 160, 3)
# pip install Pillow
img = PIL.Image.fromarray(arr)
img.save('decoded_img.jpg')

Add this code in test section of run.py.

Try pretrained models

Just to make sure that environment was setup correctly try pretrained models. Place ddpg.pkl and vae.json into the root directory and run ./run-in-docker.sh. You should see similar to the GIF above.

Credits

learning-to-drive-in-a-day's People

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.