{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "Bala Priya C",
  "title_listed": "What's in the TensorFlow Federated Box?",
  "keywords": "",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://dev.to/balapriya/what-s-in-the-tensorflow-federated-box-5b5f",
  "publish_date": "2021-04-26",
  "corpus_stage": "",
  "notes": "",
  "id": "d9048f1ada8a",
  "collected_at": "2026-10-02T14:01:40",
  "title": "What's in the TensorFlow Federated Box? - DEV Community",
  "body_markdown": "Krzysztof Ostrowski is a Research Scientist at Google, where he leads the TensorFlow Federated development team. This blog post is inspired by his talk at the OpenMined Privacy Conference.\nWhat is TensorFlow Federated?\nTensorFlow Federated(TFF) is a new development framework for Federated Computations, that typically involve computations on data that is born decentralized and stays decentralized. TFF provides a common framework for federated computations in both research and production and is an open source project within the TensorFlow ecosystem.\nWhat’s in the TensorFlow Federated library?\nFederated Computation API(FC API) that provides new abstractions, execution models and language designed for federated computations.\nHigher-level libraries and canned APIs that provide implementations of federated learning algorithms.\nRuntime and Simulation Components that provide datasets, canned training loops and single to multi-machine runtime, including flexible integration points for custom backend.\nDesign Goals for TFF\nThe TFF library has been designed so as to facilitate an easy path from research to production. In TFF, the code is serialized into a portable, language-independent and platform-independent representation.\nThe design is, therefore, motivated by the dictum:\nWrite code once, and deploy it anywhere;\nYour code shouldn’t have to change!\nUnderstanding the characteristics of Federated Computations(FC)\nIn this section, we shall seek to understand some of the characteristics of federated computations.\nDistributed Programming for privacy, anonymity and scale\n: In such systems, the client stays on-device, because it’s very sensitive. We can have millions of clients coming and going continuously. The clients are assumed to be anonymous, unreliable and stateless. No client IDs are allowed in computation. There are no one-to-one interactions between clients, only collective operations are involved.\nLet us consider the following example. Let us assume that temperature sensor readings of client devices are sensitive; The server wishes to get the percentage of client devices whose temperature sensor readings exceed a certain threshold. There’s federated broadcast of the threshold to all client devices. The client devices run a simple threshold check and send out a\n1/0\ndepending on whether\ntemperature > threshold\nis\nTrue/False\nrespectively. The server then does federated averaging on the values from the clients, which gives the fraction of devices whose temperature exceeds the threshold.\nClients and Server bear complementary responsibilities\n— the server orchestrates the training process, while the clients perform the bulk of processing, such as model training.\nSlicing and Dicing distributed (federated) values: A value is ‘federated’ if it can exist in multiple places. In our example, we may think of ‘temperature readings’ as\nfederated float32@clients\nInvolves communication and orchestration  —  collective operations, known as federated ops, rather than dealing with individual client’s data.\nTFF’s Federated Computation API\nThe program flow is expressed in a Pythonic way for better interpretability; As stated in an earlier section, all code is traced and serialized at definition time to a platform-independent representation. Here’s the code snippet showing the collective operations and on-device processing for the temperature sensor example discussed above.\n@tf.function\ndef\nexceeds_threshold_fn\n(\nreading\n,\nthreshold\n):\n#on-device processing\nreturn\ntf\n.\nto_float\n(\nreading\n>\nthreshold\n)\n@tff.federated_computation\ndef\nget_fraction_over_threshold\n(\nreadings\n,\nthreshold\n):\nreturn\ntff\n.\nfederated_mean\n(\n#collective operations\ntff\n.\nfederated_map\n(\n#collective communication\ntff\n.\ntf_computation\n(\nexceeds_threshold_fn\n),\n[\nreadings\n,\ntff\n.\nfederated_broadcast\n(\nthreshold\n)]))\nEnter fullscreen mode\nExit fullscreen mode\nTFF’s Canned and Simulation APIs\nWe shall enumerate some of the features of TFF’s Canned and Simulation APIs.\nOne-line call to create portable TFF code for federated training.\n# Just plug in your Keras model\ntrain\n=\ntff\n.\nlearning\n.\nbuild_federated_averaging_process\n(...)\nEnter fullscreen mode\nExit fullscreen mode\nTo run a simulation, we can invoke just like a Python function, similar to the example below; By default, a single-machine in-process TFF runtime is spawned in the background.\nstate\n=\ntrain\n.\ninitilaize\n()\nfor\n_\nin\nrange\n(\n5\n):\ntrain_data\n=\n_\n#pick random clients\nstate\n,\nmetrics\n=\ntrain\n.\nnext\n(\nstate\n,\ntrain_data\n)\nprint\n(\nmetrics\n.\nloss\n)\nEnter fullscreen mode\nExit fullscreen mode\nCanned TFF Executors\nCanned TFF Executors provide support for the most common scenarios. A single-machine, multi-threaded execution is spawned by default in the background, and the Canned TFF Executors facilitate remote and distributed execution. TFF executor building blocks are reusable, stackable modules that add to individual capabilities and are specifically designed for extensibility and customizability.\nCollaboration opportunities for Open Source contributors\nThere are opportunities to contribute to the federated algorithms suite, simulation infrastructure and more flexible runtime integrations.\nReferences\n[1]\nhttps://www.tensorflow.org/federated\nCover Image: Photo by\nMel Poole\non\nUnsplash",
  "metadata": {
    "title": "What's in the TensorFlow Federated Box? - DEV Community",
    "description": "Krzysztof Ostrowski is a Research Scientist at Google, where he leads the TensorFlow Federated... Tagged with python, machinelearning, computerscience.",
    "keywords": "python, machinelearning, computerscience, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/balapriya/what-s-in-the-tensorflow-federated-box-5b5f",
    "og:title": "What's in the TensorFlow Federated Box?",
    "og:description": "Krzysztof Ostrowski is a Research Scientist at Google, where he leads the TensorFlow Federated...",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzi2cq7i0bw61s0cu9d5j.jpg",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "What's in the TensorFlow Federated Box?",
    "twitter:description": "Krzysztof Ostrowski is a Research Scientist at Google, where he leads the TensorFlow Federated...",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzi2cq7i0bw61s0cu9d5j.jpg"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/d9048f1ada8a/code/body-000.txt",
      "chars": 501,
      "language": "text"
    },
    {
      "file": "attachments/d9048f1ada8a/code/body-001.txt",
      "chars": 92,
      "language": "text"
    },
    {
      "file": "attachments/d9048f1ada8a/code/body-002.txt",
      "chars": 173,
      "language": "text"
    }
  ],
  "images": [
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff1.jpg",
      "bytes": 7062,
      "reused": true,
      "local_path": "attachments/d9048f1ada8a/images/002.jpg",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff1.jpg",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff2-2.jpg",
      "bytes": 7062,
      "reused": true,
      "local_path": "attachments/d9048f1ada8a/images/003.jpg",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff2-2.jpg",
      "alt": "",
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff1.jpg",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.openmined.org%2Fcontent%2Fimages%2Fsize%2Fw1000%2F2021%2F02%2Ftff2-2.jpg",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://www.tensorflow.org/federated",
      "label": "https://www.tensorflow.org/federated",
      "type": "a"
    },
    {
      "href": "https://unsplash.com/@melpoole?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText",
      "label": "Mel Poole",
      "type": "a"
    },
    {
      "href": "https://unsplash.com/s/photos/search?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText",
      "label": "Unsplash",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:49:12Z",
  "source_url": "https://dev.to/balapriya/what-s-in-the-tensorflow-federated-box-5b5f",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 5277,
  "expected_body_images": 2,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/d9048f1ada8a/pages/source.html",
  "local_html": "attachments/d9048f1ada8a/pages/article.html",
  "body_base_path": "attachments/d9048f1ada8a/pages/",
  "body_markdown_path": "attachments/d9048f1ada8a/pages/article.md"
}