Skip to Content
Neural Network Projects with Python
book

Neural Network Projects with Python

by James Loy
February 2019
Beginner to intermediate
308 pages
7h 42m
English
Packt Publishing
Content preview from Neural Network Projects with Python

Creating neural networks in Keras

Let's take a look at how we can use Keras to build the two-layer neural network that we introduced earlier. To build a linear collection of layers, first declare a Sequential model in Keras:

from keras.models import Sequentialmodel = Sequential()

This creates an empty Sequential model that we can now add layers to. Adding layers in Keras is simple and similar to stacking Lego blocks on top of one another. We start by adding layers from the left (the layer closest to the input):

from keras.layers import Dense# Layer 1model.add(Dense(units=4, activation='sigmoid', input_dim=3))# Output Layermodel.add(Dense(units=1, activation='sigmoid'))

Stacking layers in Keras is as simple as calling the model.add() command. ...

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

Machine Learning with Python Cookbook

Machine Learning with Python Cookbook

Chris Albon

Publisher Resources

ISBN: 9781789138900Supplemental Content