Agent script

In this section, we will train an agent that will perform reinforcement learning based on the actor and critic networks. We will perform the following steps to achieve this:

  1. Create an agent class whose initial function takes in the batch size, state size, and an evaluation Boolean function, to check whether the training is ongoing.
  2. In the agent class, create the following methods:
  3. Import the actor and critic scripts:
from actor import Actorfrom critic import Critic
  1. Import numpy, randomnamedtuple, and deque from the collections package:
import numpy as npfrom numpy.random import choiceimport randomfrom collections import namedtuple, deque
  1. Create a ReplayBuffer class that adds, samples, and evaluates a buffer:
class ReplayBuffer: ...

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.