Actor script

The actor script is where the policy model is defined. We begin by importing certain modules from Keras: layers, optimizers, models, and the backend. These modules will help us to construct our neural network: Let's start by importing the required functions from Keras.

from keras import layers, models, optimizersfrom keras import backend as K
  1. We create a class called Actor, whose object takes in the parameters of the state and action size:
class Actor:          # """Actor (policy) Model. """    def __init__(self, state_size, action_size):        self.state_size = state_size        self.action_size = action_size
  1. The preceding code shows the state size, which represents the dimension of each state, and the action size, which represents the dimensions ...

Get Python Reinforcement Learning Projects 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.