Created
January 12, 2019 15:01
-
-
Save peune/b9457f4875073065f0dba571f1e319b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.layers import (Conv2D, BatchNormalization, Activation, Flatten) | |
# Build a model with 14 output nodes | |
model = Sequential() | |
model.add( Conv2D(8, (3,3), padding='same', input_shape=(28,28,1))) | |
model.add( BatchNormalization() ) | |
model.add( Activation('relu') ) | |
model.add( Conv2D(8, (3,3), strides=(2,2), padding='same') ) # -> 14,14,8 | |
model.add( BatchNormalization() ) | |
model.add( Activation('relu') ) | |
model.add( Conv2D(8, (3,3), strides=(2,2), padding='same')) # -> 7,7,8 | |
model.add( BatchNormalization() ) | |
model.add( Activation('relu') ) | |
model.add( Flatten() ) | |
model.add( Dense(10, activation='softmax') ) | |
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) | |
model.summary() | |
model.fit(X_train.reshape((X_train.shape[0],28,28,1)), Y_train, batch_size=32, epochs=5, | |
validation_data=(X_test.reshape((X_test.shape[0],28,28,1)),Y_test)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment