Skip to content
Snippets Groups Projects
_index.yaml 7.29 KiB
Newer Older
book_path: /federated/_book.yaml
project_path: /federated/_project.yaml
description: An open-source framework for machine learning and other computations on decentralized
 data. TFF has been developed to facilitate open research and experimentation.
landing_page:
  custom_css_path: /site-assets/css/style.css
  rows:
ostrowski's avatar
ostrowski committed
  - heading: "TensorFlow Federated: Machine Learning on Decentralized Data"
    items:
    - classname: devsite-landing-row-50
ostrowski's avatar
ostrowski committed
      - description: >
          <!-- Please keep the content of this file in sync with README.md -->
          <p>TensorFlow Federated (TFF) is an open-source framework for machine learning and other
          computations on decentralized data. TFF has been developed to facilitate open research and
          experimentation with
          <a href="https://ai.googleblog.com/2017/04/federated-learning-collaborative.html" class="external">Federated Learning (FL)</a>,
          an approach to machine learning where a shared global model is trained across many
          participating clients that keep their training data locally. For example, FL has been used
          to train
          <a href="https://arxiv.org/abs/1811.03604" class="external">prediction models for mobile keyboards</a>
          without uploading sensitive typing data to servers.</p>
          <p>TFF enables developers to simulate the included federated learning algorithms on their
          models and data, as well as to experiment with novel algorithms. The building blocks
          provided by TFF can also be used to implement non-learning computations, such as aggregated
          analytics over decentralized data. TFF’s interfaces are organized in two layers:</p>
      - heading: Federated Learning (FL) API
ostrowski's avatar
ostrowski committed
          This layer offers a set of high-level interfaces that allow developers to apply the
          included implementations of federated training and evaluation to their existing
          TensorFlow models.
        path: /federated/federated_learning
        icon:
          icon_name: chevron_right
          foreground: theme
          background: grey
ostrowski's avatar
ostrowski committed
      - heading: Federated Core (FC) API
ostrowski's avatar
ostrowski committed
          At the core of the system is a set of lower-level interfaces for concisely expressing
          novel federated algorithms by combining TensorFlow with distributed communication
          operators within a strongly-typed functional programming environment. This layer also
ostrowski's avatar
ostrowski committed
          serves as the foundation upon which we've built Federated Learning.
        path: /federated/federated_core
        icon:
          icon_name: chevron_right
          foreground: theme
          background: grey
ostrowski's avatar
ostrowski committed
      - description: >
          <p>TFF enables developers to declaratively express federated computations, so they could be
ostrowski's avatar
ostrowski committed
          deployed to diverse runtime environments. Included with TFF is a single-machine
          simulation runtime for experiments. Please visit the
          <a href="/federated/tutorials/federated_learning_for_image_classification">tutorials</a>
          and try it out yourself!</p>
          <p>For questions and support, find us at the
          <a href="https://stackoverflow.com/questions/tagged/tensorflow-federated">tensorflow-federated tag</a>
          on StackOverflow.</p>
      code_block: |
        <pre class = "prettyprint">
        import tensorflow as tf
        import tensorflow_federated as tff
Michael Reneer's avatar
Michael Reneer committed
        # Load simulation data.
        source, _ = tff.simulation.datasets.emnist.load_data()
        def client_data(n):
          return source.create_tf_dataset_for_client(source.client_ids[n]).map(
              lambda e: (tf.reshape(e['pixels'], [-1]), e['label'])
          ).repeat(10).batch(20)
Michael Reneer's avatar
Michael Reneer committed
        # Pick a subset of client devices to participate in training.
        train_data = [client_data(n) for n in range(3)]

Michael Reneer's avatar
Michael Reneer committed
        # Wrap a Keras model for use with TFF.
Shanshan Wu's avatar
Shanshan Wu committed
          model = tf.keras.models.Sequential([
              tf.keras.layers.Dense(10, tf.nn.softmax, input_shape=(784,),
                                    kernel_initializer='zeros')
          ])
          return tff.learning.from_keras_model(
              model,
Shanshan Wu's avatar
Shanshan Wu committed
              loss=tf.keras.losses.SparseCategoricalCrossentropy(),
              metrics=[tf.keras.metrics.SparseCategoricalAccuracy()])
Michael Reneer's avatar
Michael Reneer committed
        # Simulate a few rounds of training with the selected client devices.
        trainer = tff.learning.build_federated_averaging_process(
          model_fn,
          client_optimizer_fn=lambda: tf.keras.optimizers.SGD(0.1))
        state = trainer.initialize()
        for _ in range(5):
          state, metrics = trainer.next(state, train_data)
          print (metrics.loss)
        </pre>

  - classname: devsite-landing-row-cards
    items:
    - heading: "Federated Learning Workshop using TensorFlow Federated"
      - label: "Watch the video"
        path: https://www.youtube.com/watch?v=JBNas6Yd30A
      - label: "Visit the workshop site"
        path: https://events.withgoogle.com/demostutorials-workshop-on-federated-learning-and-analytics-2020
    - heading: "TensorFlow Federated (TFF): Machine Learning on Decentralized Data"
      youtube_id: 1YbPmkChcbo
      buttons:
      - label: "Watch the video"
        path: https://www.youtube.com/watch?v=1YbPmkChcbo
    - heading: "Introducing TensorFlow Federated"
      image_path: /resources/images/tf-logo-card-16x9.png
      path: https://blog.tensorflow.org/2019/03/introducing-tensorflow-federated.html
      buttons:
      - label: "Read on TensorFlow blog"
        path: https://blog.tensorflow.org/2019/03/introducing-tensorflow-federated.html

  - classname: devsite-landing-row-cards
    items:
    - heading: "TF Federated on GitHub"
      image_path: /resources/images/github-card-16x9.png
      path: https://github.com/tensorflow/federated
      buttons:
      - label: "View on GitHub"
        path: https://github.com/tensorflow/federated
    - heading: "Federated Learning: Collaborative Machine Learning without Centralized Training Data"
      image_path: /resources/images/google-research-card-16x9.png
      path: https://ai.googleblog.com/2017/04/federated-learning-collaborative.html
      buttons:
      - label: "Read on Google AI blog"
        path: https://ai.googleblog.com/2017/04/federated-learning-collaborative.html
    - heading: "Federated Analytics: Collaborative Data Science without Data Collection"
      image_path: /resources/images/google-research-card-16x9.png
      path: https://ai.googleblog.com/2020/05/federated-analytics-collaborative-data.html
      buttons:
      - label: "Read on Google AI blog"
        path: https://ai.googleblog.com/2020/05/federated-analytics-collaborative-data.html

  - classname: devsite-landing-row-cards
    items:
    - heading: "Making every phone smarter with Federated Learning"
      youtube_id: gbRJPa9d-VU
      buttons:
      - label: "Watch the video"
        path: https://www.youtube.com/watch?v=gbRJPa9d-VU
    - heading: "Federated learning comic book from Google AI"
      image_path: /resources/images/federated-learning-promo-card-16x9.png
      path: https://federated.withgoogle.com
      buttons:
      - label: "View the comic online"
        path: https://federated.withgoogle.com
    - heading: ""
      options:
      - hidden