January 2019
Intermediate to advanced
386 pages
11h 13m
English
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 pole. We'll use feedforward networks with one hidden layer for both the actor and the critic. Let's start!:
from collections import namedtupleimport gymimport matplotlib.pyplot as pltimport numpy as npimport tensorflow as tf
env = gym.make('CartPole-v0')