Google I/O returns May 18-20! Reserve space and build your schedule Register now


TensorFlow 1 version View source on GitHub

Learning rate scheduler.

Inherits From: Callback

schedule a function that takes an epoch index as input (integer, indexed from 0) and returns a new learning rate as output (float).
verbose int. 0: quiet, 1: update messages.

# This function keeps the learning rate at 0.001 for the first ten epochs
# and decreases it exponentially after that.
def scheduler(epoch):
  if epoch < 10:
    return 0.001
    return 0.001 * tf.math.exp(0.1 * (10 - epoch))

callback = tf.keras.callbacks.LearningRateScheduler(scheduler), labels, epochs=100, callbacks=[callback],
          validation_data=(val_data, val_labels))



View source


View source