Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keras.models import Sequential
- from keras.layers import Dense, MaxPooling2D, Conv2D, Flatten
- def build_keras_model():
- # this is the same configuration that Francois Chollet used in his cats vs dogs problem
- model = Sequential()
- # CNN layers
- model.add(Conv2D(filters=64, activation='relu', kernel_size=ksize,
- strides=strides, padding='same',
- input_shape=(image_height, image_width, num_channels)))
- model.add(MaxPooling2D(pool_size=psize))
- model.add(Conv2D(filters=128, activation='relu', kernel_size=ksize,
- strides=strides, padding='same'))
- model.add(MaxPooling2D(pool_size=psize))
- model.add(Conv2D(filters=128, activation='relu', kernel_size=ksize,
- strides=strides, padding='same'))
- model.add(MaxPooling2D(pool_size=psize))
- # 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
- #adam = Adam(lr=0.001)
- 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())
Add Comment
Please, Sign In to add comment