Coding AandC.py

We will specify the ActorNetwork class and the CriticNetwork class in AandC.py. The steps involved are as follows:

  1. Importing packages: First, we import the packages:
import tensorflow as tfimport numpy as npimport gymfrom gym import wrappersimport argparseimport pprint as ppimport sysfrom replay_buffer import ReplayBuffer
  1. Define initializers for the weights and biases: Next, we define the weights and biases initializers:
winit = tf.contrib.layers.xavier_initializer()binit = tf.constant_initializer(0.01)rand_unif = tf.keras.initializers.RandomUniform(minval=-3e-3,maxval=3e-3)regularizer = tf.contrib.layers.l2_regularizer(scale=0.0)
  1. Defining the ActorNetwork class: The ActorNetwork class is specified as follows. First, ...

Get TensorFlow Reinforcement Learning Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.