June 2018
Intermediate to advanced
318 pages
9h 24m
English
We have a pendulum that starts in a random position, and the goal of our agent is to swing the pendulum up so it stays upright. We will see how to use DDPG here. Credit for the code used in this section goes to wshuail (https://github.com/wangshuailong/reinforcement_learning_with_Tensorflow/tree/master/DDPG).
First, let's import the necessary libraries:
import tensorflow as tfimport numpy as npimport gym
Next, we define the hyperparameters as follows:
# number of steps in each episodeepsiode_steps = 500 # learning rate for actorlr_a = 0.001 # learning rate for criticlr_c = 0.002 # discount factorgamma = 0.9 # soft replacementalpha = 0.01 # replay buffer sizememory = 10000 # batch size for trainingbatch_size = 32 render ...