Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Q-Learning with Python

You're reading from   Hands-On Q-Learning with Python Practical Q-learning with OpenAI Gym, Keras, and TensorFlow

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781789345803
Length 212 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Nazia Habib Nazia Habib
Author Profile Icon Nazia Habib
Nazia Habib
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Section 1: Q-Learning: A Roadmap FREE CHAPTER
2. Brushing Up on Reinforcement Learning Concepts 3. Getting Started with the Q-Learning Algorithm 4. Setting Up Your First Environment with OpenAI Gym 5. Teaching a Smartcab to Drive Using Q-Learning 6. Section 2: Building and Optimizing Q-Learning Agents
7. Building Q-Networks with TensorFlow 8. Digging Deeper into Deep Q-Networks with Keras and TensorFlow 9. Section 3: Advanced Q-Learning Challenges with Keras, TensorFlow, and OpenAI Gym
10. Decoupling Exploration and Exploitation in Multi-Armed Bandits 11. Further Q-Learning Research and Future Projects 12. Assessments 13. Other Books You May Enjoy

Implementing your agent

Let's recreate the Taxi-v2 environment. We'll need to import numpy this time. We'll be using the term state instead of observation in this chapter for consistency with the terminology we used in Chapter 1, Brushing Up on Reinforcement Learning Concepts:

import gym
import numpy as np
env = gym.make('Taxi-v2')
state = env.reset()

Create the Q-table as follows:

Q = np.zeros([env.observation_space.n, env.action_space.n])

The Q-table is initialized as a two-dimensional numpy array of zeroes. The first three rows of the Q-table currently look like this:

State South(0) North(1) East(2) West(3) Pickup(4) Dropoff(5)
0 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0

The first column represents the state, and the other column names represent the six possible actions. The Q-values for of all the state-action pairs are currently at zero....

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime