Create a simple Sequential Model

Other topics

Simple Multi Layer Perceptron wtih Sequential Models

You can create a Sequential model by passing a list of layer instances to the constructor:

from keras.models import Sequential
from keras.layers import Dense, Activation

model = Sequential([
    Dense(32, input_dim=784),
    Activation('relu'),
    Dense(10),
    Activation('softmax'),
])

You can also simply add layers via the .add() method:

model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'))

Models must be compiled before use:

model.compile(loss='binary_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])

Contributors

Topic Id: 8850

Example Ids: 27568

This site is not affiliated with any of the contributors.