April 2018
Beginner to intermediate
500 pages
11h 26m
English
The Sequential model is a linear stack of layers. We can create a Sequential model by passing a list of layer instances to the constructor as follows:
from keras.models import Sequentialfrom keras.layers import Dense, Activationmodel = Sequential([ Dense(32, input_shape=(784,)), Activation('relu'), Dense(10), Activation('softmax'),])
We can also simply add layers via the .add() method:
model = Sequential()model.add(Dense(32, input_dim=784))model.add(Activation('relu'))
This type of model needs to know what input shape it should expect. For this reason, the first layer in a Sequential model needs to receive information about its input shape. There are several possible ways to do this:
Read now
Unlock full access