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:
- 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.
- In the agent class, create the following methods:
- Import the actor and critic scripts:
from actor import Actorfrom critic import Critic
- Import numpy, random, namedtuple, and deque from the collections package:
import numpy as npfrom numpy.random import choiceimport randomfrom collections import namedtuple, deque
- Create a ReplayBuffer class that adds, samples, and evaluates a buffer:
class ReplayBuffer: ...