Coding the class_ppo.py file

We will now code the class_ppo.py file:

  1. Import packages: First, we will import the required packages as follows:
import numpy as npimport gymimport sys
  1. Set the neural network initializers: Then, we will set the neural network parameters (we will use two hidden layers) and the initializers for the weights and biases. As we have also done in past chapters, we will use the Xavier initializer for the weights and a small positive value for the initial values of the biases:
nhidden1 = 64 nhidden2 = 64 xavier = tf.contrib.layers.xavier_initializer()bias_const = tf.constant_initializer(0.05)rand_unif = tf.keras.initializers.RandomUniform(minval=-3e-3,maxval=3e-3)regularizer = tf.contrib.layers.l2_regularizer(scale=0.0 ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.