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
Python Reinforcement Learning Projects

You're reading from  Python Reinforcement Learning Projects

Product type Book
Published in Sep 2018
Publisher Packt
ISBN-13 9781788991612
Pages 296 pages
Edition 1st Edition
Languages
Authors (3):
Sean Saito Sean Saito
Profile icon Sean Saito
Yang Wenzhuo Yang Wenzhuo
Profile icon Yang Wenzhuo
Rajalingappaa Shanmugamani Rajalingappaa Shanmugamani
Profile icon Rajalingappaa Shanmugamani
View More author details

Implementation of A3C


We will now look at how to implement A3C using Python and TensorFlow. Here, the policy network and value network share the same feature representation. We implement two kinds of policies: one is based on the CNN architecture used in DQN, and the other is based on LSTM.

We implement the FFPolicy class for the policy based on CNN:

class FFPolicy:

    def __init__(self, input_shape=(84, 84, 4), n_outputs=4, network_type='cnn'):

        self.width = input_shape[0]
        self.height = input_shape[1]
        self.channel = input_shape[2]
        self.n_outputs = n_outputs
        self.network_type = network_type
        self.entropy_beta = 0.01

        self.x = tf.placeholder(dtype=tf.float32, 
                                shape=(None, self.channel, self.width, self.height))
        self.build_model()

The constructor requires three arguments:

  1.  input_shape
  2. n_outputs
  3. network_type

 

input_shape is the size of the input image. After data preprocessing, the input is an 84x84x4...

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 $15.99/month. Cancel anytime}