Skip to Content
Keras Deep Learning Cookbook
book

Keras Deep Learning Cookbook

by Rajdeep Dua, Sujit Pal, Manpreet Singh Ghotra
October 2018
Intermediate to advanced
252 pages
6h 49m
English
Packt Publishing
Content preview from Keras Deep Learning Cookbook

How to do it...

Let's go ahead and implement the Dueling DQN agent-based Cartpole playing program. Perform the following steps to get the agent in place:

  1. Initialize the Open AI gym environment env
  2. Define the number of actions from env
  3. Create a sequential neural network
  4. Initialize the SequentualMemory with a limit of 100 and window_length of 1
  5. Initialize the BoltzmannQPolicy instance policy
  6. Create DQNAgent, as follows:
dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10,               enable_dueling_network=True, target_model_update=1e-2, policy=policy)
  1. Compile the DQNAgent with the optimization method as Adam and the loss function as mean absolute error (MAE)
  2. Call dqn.fit to find the rewards:
ENV_NAME = 'CartPole-v0' ...
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

Applied Deep Learning with Keras

Applied Deep Learning with Keras

Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme
Advanced Deep Learning with Keras

Advanced Deep Learning with Keras

Rowel Atienza, Neeraj Verma, Valerio Maggio
The Applied TensorFlow and Keras Workshop

The Applied TensorFlow and Keras Workshop

Harveen Singh Chadha, Luis Capelo, Abhranshu Bagchi, Achint Chaudhary, Vishal Chauhan, Alexis Rutherford, Subhash Sundaravadivelu

Publisher Resources

ISBN: 9781788621755Supplemental Content