Stay organized with collections
Save and categorize content based on your preferences.
These colab-based tutorials walk you
through the main TFF concepts and APIs using practical examples. Reference
documentation can be found in the TFF guides.
Getting started with federated learning
Federated Learning for image classification
introduces the key parts of the Federated Learning (FL) API, and
demonstrates how to use TFF to simulate federated learning on federated
MNIST-like data.
Federated Learning for text generation
further demonstrates how to use TFF's FL API to refine a serialized
pre-trained model for a language modeling task.
Federated Reconstruction for Matrix Factorization
introduces partially local federated learning, where some client parameters
are never aggregated on the server. The tutorial demonstrates how to use the
Federated Learning API to train a partially local matrix factorization
model.
Composing Learning Algorithms shows
how to use the TFF Learning API to easily implement new federated learning
algorithms, especially variants of Federated Averaging.
Random noise generation points out some
subtleties with using randomness in decentralized computations, and proposes
best practices and recommend patterns.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-15 UTC."],[],[],null,["# TensorFlow Federated Tutorials\n\n\u003cbr /\u003e\n\nThese [colab-based](https://colab.research.google.com/) tutorials walk you\nthrough the main TFF concepts and APIs using practical examples. Reference\ndocumentation can be found in the [TFF guides](../get_started).\n| **Note:** TFF currently requires Python 3.9 or later, but [Google Colaboratory](https://research.google.com/colaboratory/)'s hosted runtimes currently use Python 3.7, and so in order to run these notebooks you will need to use a [custom local runtime](https://research.google.com/colaboratory/local-runtimes.html).\n\n**Getting started with federated learning**\n\n- [Federated Learning for image classification](/federated/tutorials/federated_learning_for_image_classification) introduces the key parts of the Federated Learning (FL) API, and demonstrates how to use TFF to simulate federated learning on federated MNIST-like data.\n- [Federated Learning for text generation](/federated/tutorials/federated_learning_for_text_generation) further demonstrates how to use TFF's FL API to refine a serialized pre-trained model for a language modeling task.\n- [Tuning recommended aggregations for learning](/federated/tutorials/tuning_recommended_aggregators) shows how the basic FL computations in [`tff.learning`](https://www.tensorflow.org/federated/api_docs/python/tff/learning) can be combined with specialized aggregation routines offering robustness, differential privacy, compression, and more.\n- [Federated Reconstruction for Matrix Factorization](/federated/tutorials/federated_reconstruction_for_matrix_factorization) introduces partially local federated learning, where some client parameters are never aggregated on the server. The tutorial demonstrates how to use the Federated Learning API to train a partially local matrix factorization model.\n\n**Getting started with federated analytics**\n\n- [Private Heavy Hitters](/federated/tutorials/private_heavy_hitters) shows how to use [`tff.analytics.heavy_hitters`](https://www.tensorflow.org/federated/api_docs/python/tff/analytics/heavy_hitters) to build a federated analytics computation to discover private heavy hitters.\n\n**Writing custom federated computations**\n\n- [Building Your Own Federated Learning Algorithm](/federated/tutorials/building_your_own_federated_learning_algorithm) shows how to use the TFF Core APIs to implement federated learning algorithms, using Federated Averaging as an example.\n- [Composing Learning Algorithms](/federated/tutorials/composing_learning_algorithms) shows how to use the TFF Learning API to easily implement new federated learning algorithms, especially variants of Federated Averaging.\n- [Custom Federated Algorithms, Part 1: Introduction to the Federated Core](/federated/tutorials/custom_federated_algorithms_1) and [Part 2: Implementing Federated Averaging](/federated/tutorials/custom_federated_algorithms_2) introduce the key concepts and interfaces offered by the Federated Core API (FC API).\n- [Implementing Custom Aggregations](/federated/tutorials/custom_aggregators) explains the design principles behind the [`tff.aggregators`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators) module and best practices for implementing custom aggregation of values from clients to server.\n\n**Simulation best practices**\n\n- [TFF simulation with accelerators (GPU)](/federated/tutorials/simulations_with_accelerators)\n shows how TFF's high-performance runtime can be used with GPUs.\n\n- [Working with ClientData](/federated/tutorials/working_with_client_data) gives best\n practices for integrating TFF's\n [ClientData](https://www.tensorflow.org/federated/api_docs/python/tff/simulation/datasets/ClientData)-based\n simulation datasets into TFF computations.\n\n**Intermediate and advanced tutorials**\n\n- [Random noise generation](/federated/tutorials/random_noise_generation) points out some\n subtleties with using randomness in decentralized computations, and proposes\n best practices and recommend patterns.\n\n- [Sending Different Data To Particular Clients With\n federated_language.federated_select](/federated/tutorials/federated_select) introduces the\n `federated_language.federated_select` operator and gives a simple example of\n a custom federated algorithm that sends different data to different clients.\n\n- [Client-efficient large-model federated learning via federated_select and\n sparse aggregation](/federated/tutorials/sparse_federated_learning) shows how TFF can be\n used to train a very large model where each client device only downloads and\n updates a small part of the model, using\n `federated_language.federated_select` and sparse aggregation.\n\n- [Federated Learning with Differential Privacy in TFF](/federated/tutorials/federated_learning_with_differential_privacy)\n demonstrates how to use TFF to train models with user-level differential\n privacy."]]