tf.keras.callbacks.LearningRateScheduler

View source on GitHub

Learning rate scheduler.

Inherits From: Callback

tf.keras.callbacks.LearningRateScheduler(
    schedule, verbose=0
)

Arguments:

# 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
  else:
    return 0.001 * tf.math.exp(0.1 * (10 - epoch))

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

Methods

set_model

View source

set_model(
    model
)

set_params

View source

set_params(
    params
)