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...

We will be using a neural network to build the AI agent that plays Cartpole. The neural network will have input with four parameters, three hidden layers, and output with two possible outputs: 0 or 1:

  1. Keras makes it simple to implement a basic neural network. The following code creates an empty sequential model:
model = Sequential()model.add(Dense(24, input_dim=self.state_size, activation='relu'))model.add(Dense(24, activation='relu'))model.add(Dense(self.action_size, activation='linear'))model.compile(loss='mse',              optimizer=Adam(lr=self.learning_rate))

We are using linear activation, mean square error (MSEloss, and the Adam optimizer as the characteristics of the neural network.

  1. For a neural net to predict based on the ...
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