We will now code the class_ppo.py file:
- Import packages: First, we will import the required packages as follows:
import numpy as npimport gymimport sys
- 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 ...