# tff.learning.optimizers.schedule_learning_rate

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Returns an optimizer with scheduled learning rate.

    tff.learning.optimizers.schedule_learning_rate(
        optimizer: https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers/Optimizer,
        schedule_fn: Callable[[optimizer_base.Int], optimizer_base.Float]
    ) -> https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers/Optimizer

The returned optimizer will use a learning rate of `schedule_fn(i)` for the
`i`-th invocation of its `next` method, indexing from 0.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `optimizer` | A [`tff.learning.optimizers.Optimizer`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers/Optimizer) which uses a learning rate. |
| `schedule_fn` | A callable mapping integer round number to a floating point learning rate. To be invoked in the context of a [`tff.tensorflow.computation`](https://www.tensorflow.org/federated/api_docs/python/tff/tensorflow/computation), thus should support a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) input. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A [`tff.learning.optimizers.Optimizer`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers/Optimizer). ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `KeyError` | If the provided `optimizer`'s state is not a dictionary with learning rate stored under the [`tff.learning.optimizers.LEARNING_RATE_KEY`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers#LEARNING_RATE_KEY) key. |

<br />