In this tutorial, I will walk you through how to use Deep Q Learning to create an AI that learns visually (from pixels) and learns how to drive, solving CarRacing-v0. This software can be adapted with tuning to solve a wide variety of reinforcement learning problems.
- Read the seminal paper Playing Atari with Deep Reinforcement Learning written by the Deepmind team.
- Adapted from Deep Q-Learning with Keras and Gym
- Uses the Open AI Gym set of reinforcement learning libraries
We will use Python 2.7. Check that you have python installed:
python
We will use gym for the CarRacing-v0 environment, random for making explore/exploit decisions, numpy for array manipulation, collections for storing our "memory" of past states, and keras for creating the neural nets.
pip install gym
pip install keras
pip install tensorflow
Now for the code. Create a new file for our code deepqlearning.py. Let's start by importing the libraries we will need:
import gym
import random
import numpy
from collections import deque
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
python deepqlearning.py