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 O’Reilly online learning.

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