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

Instantiate a sequential model

Next, we instantiate a sequential model and add the following layers:

  • A simple RNN
  • A dense layer with one output

Following are the steps of a simple RNN:

  1. The next code listing shows model creation and compilation:
model = Sequential() model.add(SimpleRNN(n_neurons, batch_input_shape=(n_batch, X.shape[1], X.shape[2]), stateful=True)) model.add(Dense(1))
  1. Then, we compile the model using model. compile(..) with loss and optimizers, shown as follows:
model.compile(loss='mean_squared_error', optimizer='adam')

We are using mean squared error (MSE) as the loss function and Adam as an optimizer. MSE is a loss function that uses a sum of squared difference between the predicted value and actual value divided b ...

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