Skip to content

Instantly share code, notes, and snippets.

@Yuvnish017
Last active Jul 16, 2021
Embed
What would you like to do?
OCR
def step_decay(epoch):
initial_learning_rate = 0.001
dropEvery = 10
factor = 0.5
lr = initial_learning_rate*(factor**np.floor((1 + epoch)/dropEvery))
return float(lr)
checkpoint = ModelCheckpoint('maths_symbol_and_digits_recognition.h5',
monitor='val_loss', save_best_only=True,
verbose=1, mode='min')
callbacks = [checkpoint, LearningRateScheduler(step_decay)]
aug = ImageDataGenerator(zoom_range=0.1,
width_shift_range=0.05,
height_shift_range=0.05)
hist = model.fit(aug.flow(X_train, Y_train, batch_size=128),
batch_size=128, epochs=100,
validation_data=(X_test, Y_test))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment