Last active
September 22, 2018 19:00
-
-
Save mjbhobe/a061f7a7e85ff9eca92b11e983487d3b 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.models import Sequential | |
from keras.layers import Dense, MaxPooling2D, Conv2D, Flatten | |
def build_keras_model(): | |
model = Sequential() | |
# CNN layer | |
model.add(Conv2D(filters=32, kernel_size=3, strides=1, padding='same', activation='elu', | |
input_shape=(image_height, image_width, num_channels))) | |
model.add(Conv2D(filters=32, kernel_size=3, strides=1, padding='same', activation='elu')) | |
model.add(MaxPooling2D(pool_size=2)) | |
model.add(Conv2D(filters=64, kernel_size=3, strides=1, padding='same', activation='elu')) | |
model.add(Conv2D(filters=64, kernel_size=3, strides=1, padding='same', activation='elu')) | |
model.add(MaxPooling2D(pool_size=2)) | |
model.add(Conv2D(filters=128, kernel_size=3, strides=1, padding='same', activation='elu')) | |
model.add(Conv2D(filters=128, kernel_size=3, strides=1, padding='same', activation='elu')) | |
model.add(MaxPooling2D(pool_size=2)) | |
# Flatten | |
model.add(Flatten()) | |
# Dense (fully connected) layers | |
model.add(Dense(512, activation='relu')) | |
# output layer with softmax | |
model.add(Dense(10, activation='softmax')) | |
# compile with categorical_crossentropy loss function & adam optimizer | |
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) | |
return model | |
# create the model & show structure | |
kr_base_model = build_keras_model() | |
print(kr_base_model.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment