Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Deep Learning with TensorFlow

You're reading from  Deep Learning with TensorFlow

Product type Book
Published in Apr 2017
Publisher Packt
ISBN-13 9781786469786
Pages 320 pages
Edition 1st Edition
Languages
Authors (3):
Giancarlo Zaccone Giancarlo Zaccone
Profile icon Giancarlo Zaccone
Md. Rezaul Karim Md. Rezaul Karim
Profile icon Md. Rezaul Karim
Ahmed Menshawy Ahmed Menshawy
Profile icon Ahmed Menshawy
View More author details

Table of Contents (11) Chapters

Preface 1. Getting Started with Deep Learning 2. First Look at TensorFlow 3. Using TensorFlow on a Feed-Forward Neural Network 4. TensorFlow on a Convolutional Neural Network 5. Optimizing TensorFlow Autoencoders 6. Recurrent Neural Networks 7. GPU Computing 8. Advanced TensorFlow Programming 9. Advanced Multimedia Programming with TensorFlow 10. Reinforcement Learning

FrozenLake-v0 implementation problem

Here we report a basic Q-learning implementation for the FrozenLake-v0 problem.

Import the following two basic libraries:

import gym 
import numpyasnp

Then, we load the FrozenLake-v0 environment:

environment = gym.make('FrozenLake-v0')

Then, we build the Q-learning table; it has the dimensions SxA, where S is the dimension of the observation space, S, while A is the dimension of the action space, A:

S = environment.observation_space.n 
A = environment.action_space.n

The FrozenLake environment provides a state for each block, and four actions (that is, the four directions of movement), giving us a 16x4 table of Q-values to initialize:

Q = np.zeros([S,A])

Then, we define the a parameter for the training rule and the discount g factor:

alpha = .85 
gamma = .99

We fix the total number of episodes (trials):

num_episodes = 2000

Then, we initialize the rList, where we&apos...

lock icon The rest of the chapter is locked
arrow left Previous Chapter
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 $15.99/month. Cancel anytime}