Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@munhra
Created October 29, 2018 16:23
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 munhra/606e32a41baa1b09499524bd8e64c420 to your computer and use it in GitHub Desktop.
Save munhra/606e32a41baa1b09499524bd8e64c420 to your computer and use it in GitHub Desktop.
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.40)) #0.4 removed as it is bad of tflite # 0.25
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.25)) #0.25 removed as it is bad of tflite # 0.5
model.add(Dense(num_classes, activation='sigmoid')) #sigmoid
model.compile(loss=keras.losses.binary_crossentropy,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
filepath="weights-improvement-{epoch:02d}-{val_acc:.2f}.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max', period=5)
callbacks_list = [checkpoint]
model.fit(x_train, y_train,
batch_size=batch_size,
epochs=epochs,
verbose=1,
callbacks=callbacks_list,
validation_data=(x_test, y_test))
score = model.evaluate(x_test, y_test, verbose=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment