Skip to Content
Deep Learning Quick Reference
book

Deep Learning Quick Reference

by Mike Bernico
March 2018
Intermediate to advanced
272 pages
7h 53m
English
Packt Publishing
Content preview from Deep Learning Quick Reference

Neural network architecture

Now that we've defined the input and output, we can take a look at the code for the network.

from keras.layers import Input, Densefrom keras.models import Modeldef build_network(input_features=None):    inputs = Input(shape=(input_features,), name="input")    x = Dense(32, activation='relu', name="hidden")(inputs)    prediction = Dense(1, activation='linear', name="final")(x)    model = Model(inputs=inputs, outputs=prediction)    model.compile(optimizer='adam', loss='mean_absolute_error')    return model

That's all there is to it! We can then use this code to build a neural network instance suitable for our problem simply by calling it, as follows:

model = build_network(input_features=10)

Before we get to that, however, let's review ...

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

Keras Deep Learning Cookbook

Keras Deep Learning Cookbook

Rajdeep Dua, Sujit Pal, Manpreet Singh Ghotra
Deep Learning with Keras

Deep Learning with Keras

Antonio Gulli, Sujit Pal

Publisher Resources

ISBN: 9781788837996Supplemental Content