# tf.keras.callbacks.LearningRateScheduler

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/callbacks/LearningRateScheduler) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/callbacks.py#L1347-L1396) |

Learning rate scheduler.

Inherits From: [`Callback`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/callbacks/Callback)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.callbacks.LearningRateScheduler`](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/LearningRateScheduler)

<br />

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

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `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. |

<br />

    # 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](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/callbacks.py#L465-L466)

    set_model(
        model
    )

### `set_params`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/callbacks.py#L462-L463)

    set_params(
        params
    )