Deep Q Network

The third in my series on RL that I created in graduate school at Georgia Tech will be on the Q-Learning algorithm. I will use the algorithm to “solve” the OpenAI CartPole environment.

If you missed any of the previous blogs here is the first and second.

Please go to my GitHub repo and get the 05-DQN Juypter Notebook and follow along. It will make this a lot easier and will fill you in on any of the missing pieces that I leave out in this write up. Also, I can’t put code into these posts without some plugins that are not allowed on my current tier.

I skipped over my neural network notebook as it is basically some background knowledge and not much code. If you are going through the series do go back and look through it.

In 2015, Google DeepMind (link) published a paper in Nature magazine that combined a neural network with RL for the first time. They understood that using function approximation from neural networks would open up this algorithm to a much larger environment. They used ONLY the raw pixels and the score for the inputs and were able to master quite a few Atari games.

Google DeepMind used a convolution layer to transcribe the pixels to input which I don’t do here. At some point, I might try and recreate some of their results.

There are a few key differences from Q-Learner and DQN. The first is that a Q-Learner would process at each step that current set of observable. DQN uses what they call experience replay. The algorithm stores up all of the observable and then at set times they would grab a batch of them and process on them. They would the fit that batch on the NN and use the built in back propagation to train the network.

Take a look at the notebook and I go through the algorithm against the same CartPole environment.

Please, download the notebook and give it a try. I even challenge you at the end to beat my solution in fewer iterations.

Open in Google Colab05-DQN.ipynb

One thought on “Deep Q Network”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s