File size: 388 Bytes
24bf069 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import tensorflow as tf
def lr_scheduler(epoch, lr):
if epoch < 3:
return lr
else:
return lr * tf.math.exp(-0.1)
early_stopping = tf.keras.callbacksEarlyStopping(monitor='val_loss', patience=4, restore_best_weights=True)
lr_scheduler_callback = tf.keras.callbacksLearningRateScheduler(lr_scheduler)
optimizer = tf.keras.optimizers.Adam(learning_rate=0.001) |