Created
September 27, 2018 15:54
-
-
Save mjbhobe/cf895231aab8fa45a2a23da1351d185d 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 Conv2D, MaxPooling2D, Flatten, Dense, Dropout | |
def build_model(): | |
model = Sequential() | |
# add Convolutional layers | |
model.add(Conv2D(filters=32, kernel_size=(3,3), activation='relu', padding='same', | |
input_shape=(image_height, image_width, num_channels))) | |
model.add(MaxPooling2D(pool_size=(2,2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding='same')) | |
model.add(MaxPooling2D(pool_size=(2,2))) | |
model.add(Conv2D(filters=64, kernel_size=(3,3), activation='relu', padding='same')) | |
model.add(MaxPooling2D(pool_size=(2,2))) | |
model.add(Flatten()) | |
# Densely connected layers | |
model.add(Dense(128, activation='relu')) | |
# output layer | |
model.add(Dense(num_classes, activation='softmax')) | |
# compile with adam optimizer & categorical_crossentropy loss function | |
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) | |
return model | |
model = build_model() | |
print(model.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment