Let's start with the recipe:
- The first step, as always, is importing modules. Besides the usual modules, in this case, we will import gym so that we can use the different environments provided by it:
import gymimport numpy as npimport tensorflow as tfimport matplotlib.pyplot as plt
- Next, we create a RlAgent class. The class is made with three methods--the __init__ method initializes the NN size and creates the computational graph. Here, we employed the TensorFlow function, tf.multinomial, to make the decision of the possible action to take. The function returns the action based on the sigmoidal values of the nine output neurons of our network. This ensures that the network chooses the final action probabilistically. The ...