MCPcopy Create free account
hub / github.com/modAL-python/modAL / create_keras_model

Function create_keras_model

examples/keras_integration.py:16–34  ·  view source on GitHub ↗

This function compiles and returns a Keras model. Should be passed to KerasClassifier in the Keras scikit-learn API.

()

Source from the content-addressed store, hash-verified

14
15# build function for the Keras' scikit-learn API
16def create_keras_model():
17 """
18 This function compiles and returns a Keras model.
19 Should be passed to KerasClassifier in the Keras scikit-learn API.
20 """
21
22 model = Sequential()
23 model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)))
24 model.add(Conv2D(64, (3, 3), activation='relu'))
25 model.add(MaxPooling2D(pool_size=(2, 2)))
26 model.add(Dropout(0.25))
27 model.add(Flatten())
28 model.add(Dense(128, activation='relu'))
29 model.add(Dropout(0.5))
30 model.add(Dense(10, activation='softmax'))
31
32 model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
33
34 return model
35
36
37# create the classifier

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…