The full implementation of DPG can be downloaded from our GitHub (https://github.com/PacktPublishing/Python-Reinforcement-Learning-Projects). To train an agent for CartPole, run the following command under the src folder:

python train.py -t CartPole-v0 -d cpu

There are two arguments in train.py. One is -t, or --task, indicating the name of the classic control task you want to test. The other one is -d, or --device, which specifies the device (CPU or GPU) that you want to use to train the actor-critic network. Since the dimensions of the state spaces of these classic control tasks are relatively low compared to the Atari environment, using the CPU to train the agent is fast enough. It should only take several minutes to finish. ...

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.