Skip to Main Content
Hands-On Reinforcement Learning with Python
book

Hands-On Reinforcement Learning with Python

by Sudharsan Ravichandiran
June 2018
Intermediate to advanced content levelIntermediate to advanced
318 pages
9h 24m
English
Packt Publishing
Content preview from Hands-On Reinforcement Learning with Python

Swinging a pendulum

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Deep Learning with Python

Advanced Deep Learning with Python

Ivan Vasilev

Publisher Resources

ISBN: 9781788836524Supplemental Content