Skip to content

Instantly share code, notes, and snippets.

@evmcheb
Created October 11, 2019 14:32
Show Gist options
  • Save evmcheb/bb98d3869bbd9ad952649003328c9714 to your computer and use it in GitHub Desktop.
Save evmcheb/bb98d3869bbd9ad952649003328c9714 to your computer and use it in GitHub Desktop.
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, Conv2D, MaxPooling2D, GlobalAveragePooling2D
model = Sequential()
model.add(Conv2D(filters=16, kernel_size=(3, 3), input_shape=(100, 100, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
model.add(Conv2D(filters=32, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.4))
model.add(Flatten())
model.add(Dense(1, activation='sigmoid'))
print(model.summary())
model.compile(loss="binary_crossentropy", optimizer="adam", metrics=["accuracy"])
history = model.fit(x_train, y_train, batch_size=32, epochs=150,
validation_data=(x_test, y_test),
verbose=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment