Playing cart pole with A2C

In this section, we'll implement an agent that tries to play the cart pole game with the help of A2C. We'll do this with the familiar tools: the OpenAI Gym and TensorFlow. Recall that the state of the cart-pole environment is described by the position and angle of the cart and the poleWe'll use feedforward networks with one hidden layer for both the actor and the critic. Let's start!:

  1. First, we'll do the imports:
from collections import namedtupleimport gymimport matplotlib.pyplot as pltimport numpy as npimport tensorflow as tf
  1. Nextwe'll create the environment:
env = gym.make('CartPole-v0')
  1. Then, we'll add some of the hyperparameters, which describe the training. We'll take the INPUT_SIZE and ACTIONS_COUNT ...

Get Python Deep Learning - Second Edition now with O’Reilly online learning.

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