O'Reilly logo

Python Reinforcement Learning Projects by Rajalingappaa Shanmugamani, Yang Wenzhuo, Sean Saito

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required