Skip to content

Instantly share code, notes, and snippets.

@ResidentMario
Created January 28, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ResidentMario/9f413d5e7d89b98bf731f493babf66c7 to your computer and use it in GitHub Desktop.
Save ResidentMario/9f413d5e7d89b98bf731f493babf66c7 to your computer and use it in GitHub Desktop.
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.losses import binary_crossentropy
from keras.callbacks import EarlyStopping
from keras.optimizers import RMSprop
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), input_shape=(128, 128, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss=binary_crossentropy,
optimizer=RMSprop(lr=0.0005), # half of the default lr
metrics=['accuracy'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment