February 2019
Beginner to intermediate
308 pages
7h 42m
English
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. ...