# Module: tff.learning

<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) |

Libraries for building federated learning algorithms.

Currently, [`tff.learning`](https://www.tensorflow.org/federated/api_docs/python/tff/learning) provides a few types of functionality.

- Algorithmic building blocks (see [`tff.learning.templates`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/templates)) for constructing federated learning algorithms. These are algorithms centered around the client work, server work, broadcast, or aggregation steps of a federated algorithms, and are intended to compose in a somewhat modular fashion.
- End-to-end federated learning algorithms (such as [`tff.learning.algorithms.build_weighted_fed_avg`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/algorithms/build_weighted_fed_avg)) that combine broadcast, client work, aggregation, and server update logic into a single algorithm (often by composing the building blocks discussed above). This library also provides end-to-end algorithms for federated evaluation (see `tff.learning.build_federated_evaluation`).
- Functionality supporting the development of the algorithms above. This includes [`tff.learning.optimizers`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers), [`tff.learning.metrics`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/metrics) and recommended aggregators, such as [`tff.learning.robust_aggregator`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/robust_aggregator).

The library also contains classes of models that are used for the purposes of
model training. See [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel) for the overall base
class, and
[`tff.learning.models`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models) for related model classes.

## Modules

[`algorithms`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/algorithms) module: Libraries providing implementations of federated learning algorithms.

[`metrics`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/metrics) module: Libraries for working with metrics in federated learning algorithms.

[`models`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models) module: Libraries for working with models in federated learning algorithms.

[`optimizers`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/optimizers) module: Libraries for optimization algorithms.

[`programs`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/programs) module: Package of methods for compositional federated program logic.

[`templates`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/templates) module: Libraries of specialized processes used for building learning algorithms.

## Classes

[`class ClientWeighting`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/ClientWeighting): Enum for built-in methods for weighing clients.

[`class LoopImplementation`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/LoopImplementation): An enum to specify which implementation of the training loop to use.

## Functions

[`add_debug_measurements(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/add_debug_measurements): Adds measurements suitable for debugging learning processes.

[`add_debug_measurements_with_mixed_dtype(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/add_debug_measurements_with_mixed_dtype): Adds measurements suitable for debugging learning processes.

[`compression_aggregator(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/compression_aggregator): Creates aggregator with compression and adaptive zeroing and clipping.

[`ddp_secure_aggregator(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/ddp_secure_aggregator): Creates aggregator with adaptive zeroing and distributed DP.

[`dp_aggregator(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/dp_aggregator): Creates aggregator with adaptive zeroing and differential privacy.

[`robust_aggregator(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/robust_aggregator): Creates aggregator for mean with adaptive zeroing and clipping.

[`secure_aggregator(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/secure_aggregator): Creates secure aggregator with adaptive zeroing and clipping.