CINXE.COM

Random noise generation in TFF  |  TensorFlow Federated

<!doctype html> <html lang="en" dir="ltr"> <head> <base href="https://www.tensorflow.org/federated/tutorials/random_noise_generation"> <meta name="google-signin-client-id" content="157101835696-ooapojlodmuabs2do2vuhhnf90bccmoi.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="TensorFlow"> <meta property="og:type" content="website"> <meta name="theme-color" content="#ff6f00"> <meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/tensorflow/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin> <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&amp;display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&amp;family=Material+Symbols+Outlined&amp;display=block"> <link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/css/app.css"> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/favicon.png"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/apple-touch-icon-180x180.png"> <link rel="canonical" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation"> <link rel="search" type="application/opensearchdescription+xml" title="TensorFlow" href="https://www.tensorflow.org/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation"> <link rel="alternate" hreflang="x-default" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation"> <link rel="alternate" hreflang="ar" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=ar"> <link rel="alternate" hreflang="bn" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=bn"> <link rel="alternate" hreflang="fa" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=fa"> <link rel="alternate" hreflang="fr" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=fr"> <link rel="alternate" hreflang="he" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=he"> <link rel="alternate" hreflang="hi" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=hi"> <link rel="alternate" hreflang="id" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=id"> <link rel="alternate" hreflang="it" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=it"> <link rel="alternate" hreflang="ja" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=ja"> <link rel="alternate" hreflang="ko" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=ko"> <link rel="alternate" hreflang="pl" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=pl"> <link rel="alternate" hreflang="pt-BR" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=pt-br"> <link rel="alternate" hreflang="ru" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=ru"> <link rel="alternate" hreflang="es-419" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=es-419"> <link rel="alternate" hreflang="th" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=th"> <link rel="alternate" hreflang="tr" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=tr"> <link rel="alternate" hreflang="vi" href="https://www.tensorflow.org/federated/tutorials/random_noise_generation?hl=vi"> <title>Random noise generation in TFF &nbsp;|&nbsp; TensorFlow Federated</title> <meta property="og:title" content="Random noise generation in TFF &nbsp;|&nbsp; TensorFlow Federated"> <meta property="og:url" content="https://www.tensorflow.org/federated/tutorials/random_noise_generation"> <meta property="og:image" content="https://www.tensorflow.org/static/images/tf_logo_social.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="675"> <meta property="og:locale" content="en"> <meta name="twitter:card" content="summary_large_image"> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Random noise generation in TFF" } </script> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Federated", "item": "https://www.tensorflow.org/federated" },{ "@type": "ListItem", "position": 2, "name": "Random noise generation in TFF", "item": "https://www.tensorflow.org/federated/tutorials/random_noise_generation" }] } </script> <link rel="stylesheet" href="/extras.css"> <meta http-equiv="X-Translated-By" content="Google"> <meta http-equiv="X-Translated-To" content="cs"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=corsproxy" data-sourceurl="https://www.tensorflow.org/federated/tutorials/random_noise_generation"></script> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/exm=corsproxy/ed=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=phishing_protection" data-phishing-protection-enabled="false" data-forms-warning-enabled="true" data-source-url="https://www.tensorflow.org/federated/tutorials/random_noise_generation"></script> <meta name="robots" content="none"> </head> <body class="" template="page" theme="tensorflow-theme" type="article" layout="docs" display-toc pending> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/exm=corsproxy,phishing_protection/ed=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=navigationui" data-environment="prod" data-proxy-url="https://www-tensorflow-org.translate.goog" data-proxy-full-url="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" data-source-url="https://www.tensorflow.org/federated/tutorials/random_noise_generation" data-source-language="pl" data-target-language="cs" data-display-language="en-GB" data-detected-source-language="" data-is-source-untranslated="false" data-source-untranslated-url="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://www.tensorflow.org/federated/tutorials/random_noise_generation&amp;anno=2" data-client="tr"></script><devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"><devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner"> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"><button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"><a href="https://www-tensorflow-org.translate.goog/?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="tensorFlow" track-metadata-position="nav" track-metadata-eventdetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/lockup.svg" class="devsite-site-logo" alt="TensorFlow"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list"> <li class="devsite-breadcrumb-item "></li> </ul></span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"><devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"><tab> <a href="https://www-tensorflow-org.translate.goog/install?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/install" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - install" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Install" track-name="install"> Install </a> </tab> <tab class="devsite-dropdown "> <a href="https://www-tensorflow-org.translate.goog/learn?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/learn" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - learn" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Learn" track-name="learn"> Learn </a> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Learn" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/learn" track-metadata-position="nav - learn" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Learn" track-name="learn" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column tfo-menu-column-learn"> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/learn?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/learn" track-metadata-position="nav - learn" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Introduction </div> <div class="devsite-nav-item-description"> New to TensorFlow? </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tutorials?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/tutorials" track-metadata-position="nav - learn" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Tutorials </div> <div class="devsite-nav-item-description"> Learn how to use TensorFlow with end-to-end examples </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/guide?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/guide" track-metadata-position="nav - learn" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Guide </div> <div class="devsite-nav-item-description"> Learn framework concepts and components </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/learn-ml?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources/learn-ml" track-metadata-position="nav - learn" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Learn ML </div> <div class="devsite-nav-item-description"> Educational resources to master your path with TensorFlow </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown "> <a href="https://www-tensorflow-org.translate.goog/api?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/api" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - api" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api"> API </a> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for API" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/api" track-metadata-position="nav - api" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/api/stable?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/api/stable" track-metadata-position="nav - api" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> TensorFlow (v2.16.1) </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/versions?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/versions" track-metadata-position="nav - api" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Versions… </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://js.tensorflow.org/api/latest/" track-type="nav" track-metadata-eventdetail="https://js.tensorflow.org/api/latest/" track-metadata-position="nav - api" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> TensorFlow.js </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/lite/api_docs?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/lite/api_docs" track-metadata-position="nav - api" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> TensorFlow Lite </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tfx/api_docs?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/tfx/api_docs" track-metadata-position="nav - api" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> TFX </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown devsite-active "> <a href="https://www-tensorflow-org.translate.goog/resources?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/resources" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - resources" track-metadata-module="primary nav" aria-label="Resources, selected" data-category="Site-Wide Custom Events" data-label="Tab: Resources" track-name="resources"> Resources </a> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Resources" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources" track-metadata-position="nav - resources" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Resources" track-name="resources" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>LIBRARIES</li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/js?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/js" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> TensorFlow.js </div> <div class="devsite-nav-item-description"> Develop web ML applications in JavaScript </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/lite?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/lite" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> TensorFlow Lite </div> <div class="devsite-nav-item-description"> Deploy ML on mobile, microcontrollers and other edge devices </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tfx?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/tfx" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> TFX </div> <div class="devsite-nav-item-description"> Build production ML pipelines </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/libraries-extensions?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources/libraries-extensions" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> All libraries </div> <div class="devsite-nav-item-description"> Create advanced models and extend TensorFlow </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>RESOURCES</li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/models-datasets?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources/models-datasets" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="resources" tooltip> <div class="devsite-nav-item-title"> Models &amp; datasets </div> <div class="devsite-nav-item-description"> Pre-trained models and datasets built by Google and the community </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/tools?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources/tools" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="resources" tooltip> <div class="devsite-nav-item-title"> Tools </div> <div class="devsite-nav-item-description"> Tools to support and accelerate TensorFlow workflows </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/responsible_ai?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/responsible_ai" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="resources" tooltip> <div class="devsite-nav-item-title"> Responsible AI </div> <div class="devsite-nav-item-description"> Resources for every stage of the ML workflow </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/recommendation-systems?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/resources/recommendation-systems" track-metadata-position="nav - resources" track-metadata-module="tertiary nav" track-metadata-module_headline="resources" tooltip> <div class="devsite-nav-item-title"> Recommendation systems </div> <div class="devsite-nav-item-description"> Build recommendation systems with open source tools </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown "> <a href="https://www-tensorflow-org.translate.goog/community?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/community" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community"> Community </a> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Community" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/community" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/community/groups?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/community/groups" track-metadata-position="nav - community" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Groups </div> <div class="devsite-nav-item-description"> User groups, interest groups and mailing lists </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/community/contribute?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/community/contribute" track-metadata-position="nav - community" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Contribute </div> <div class="devsite-nav-item-description"> Guide for contributing to code and documentation </div></a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://blog.tensorflow.org/" track-type="nav" track-metadata-eventdetail="https://blog.tensorflow.org/" track-metadata-position="nav - community" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Blog </div> <div class="devsite-nav-item-description"> Stay up to date with all things TensorFlow </div></a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://discuss.tensorflow.org" track-type="nav" track-metadata-eventdetail="https://discuss.tensorflow.org" track-metadata-position="nav - community" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Forum </div> <div class="devsite-nav-item-description"> Discussion platform for the TensorFlow community </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown "> <a href="https://www-tensorflow-org.translate.goog/about?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/about" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - why tensorflow" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Why TensorFlow" track-name="why tensorflow"> Why TensorFlow </a> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Why TensorFlow" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/about" track-metadata-position="nav - why tensorflow" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Why TensorFlow" track-name="why tensorflow" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/about?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/about" track-metadata-position="nav - why tensorflow" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> About </div></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/about/case-studies?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/about/case-studies" track-metadata-position="nav - why tensorflow" track-metadata-module="tertiary nav" tooltip> <div class="devsite-nav-item-title"> Case studies </div></a></li> </ul> </div> </div> </div> </tab> </nav> </devsite-tabs> </div><devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="TensorFlow Federated" tenant-name="TensorFlow"> <form class="devsite-search-form" action="https://www.tensorflow.org/s/results" method="GET"> <div class="devsite-search-container"><button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"><input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value=""> <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"><kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div><devsite-language-selector> <ul role="presentation"> <li role="presentation"><a role="menuitem" lang="en">English</a></li> <li role="presentation"><a role="menuitem" lang="es_419">Español – América Latina</a></li> <li role="presentation"><a role="menuitem" lang="fr">Français</a></li> <li role="presentation"><a role="menuitem" lang="id">Indonesia</a></li> <li role="presentation"><a role="menuitem" lang="it">Italiano</a></li> <li role="presentation"><a role="menuitem" lang="pl">Polski</a></li> <li role="presentation"><a role="menuitem" lang="pt_br">Português – Brasil</a></li> <li role="presentation"><a role="menuitem" lang="vi">Tiếng Việt</a></li> <li role="presentation"><a role="menuitem" lang="tr">Türkçe</a></li> <li role="presentation"><a role="menuitem" lang="ru">Русский</a></li> <li role="presentation"><a role="menuitem" lang="he">עברית</a></li> <li role="presentation"><a role="menuitem" lang="ar">العربيّة</a></li> <li role="presentation"><a role="menuitem" lang="fa">فارسی</a></li> <li role="presentation"><a role="menuitem" lang="hi">हिंदी</a></li> <li role="presentation"><a role="menuitem" lang="bn">বাংলা</a></li> <li role="presentation"><a role="menuitem" lang="th">ภาษาไทย</a></li> <li role="presentation"><a role="menuitem" lang="zh_cn">中文 – 简体</a></li> <li role="presentation"><a role="menuitem" lang="ja">日本語</a></li> <li role="presentation"><a role="menuitem" lang="ko">한국어</a></li> </ul> </devsite-language-selector> <a class="devsite-header-link devsite-top-button button gc-analytics-event" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow" data-category="Site-Wide Custom Events" data-label="Site header link"> GitHub </a> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section "> <div class="devsite-header-background"> <div class="devsite-product-id-row"> <div class="devsite-product-description-row"> <ul class="devsite-breadcrumb-list"> <li class="devsite-breadcrumb-item "><a href="https://www-tensorflow-org.translate.goog/federated?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="TensorFlow Federated"> Federated </a></li> </ul> </div> </div> <div class="devsite-doc-set-nav-row"><devsite-tabs class="lower-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Lower tabs"><tab> <a href="https://www-tensorflow-org.translate.goog/federated?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/federated" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - overview" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Overview" track-name="overview"> Overview </a> </tab> <tab class="devsite-active"> <a href="https://www-tensorflow-org.translate.goog/federated/tutorials/tutorials_overview?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/federated/tutorials/tutorials_overview" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - tutorials" track-metadata-module="primary nav" aria-label="Tutorials, selected" data-category="Site-Wide Custom Events" data-label="Tab: Tutorials" track-name="tutorials"> Tutorials </a> </tab> <tab> <a href="https://www-tensorflow-org.translate.goog/federated/get_started?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/federated/get_started" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - guide" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Guide" track-name="guide"> Guide </a> </tab> <tab> <a href="https://www-tensorflow-org.translate.goog/federated/api_docs/python/tff?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" track-metadata-eventdetail="https://www.tensorflow.org/federated/api_docs/python/tff" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - api" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api"> API </a> </tab> </nav> </devsite-tabs> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars> <div class="devsite-book-nav-filter"><span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"><button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"><a href="https://www-tensorflow-org.translate.goog/?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="tensorFlow" track-metadata-position="nav" track-metadata-eventdetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/lockup.svg" class="devsite-site-logo" alt="TensorFlow"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list"> <li class="devsite-breadcrumb-item "></li> </ul></span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/install?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Install" track-name="install" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Install </span> <span class="devsite-nav-icon material-icons" data-icon="forward"> </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/learn?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Learn" track-name="learn" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Learn </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Learn" track-name="learn"> <span class="devsite-nav-text" tooltip menu="Learn"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Learn"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/api?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> API </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api"> <span class="devsite-nav-text" tooltip menu="API"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="API"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Resources" track-name="resources" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Resources </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Resources" track-name="resources"> <span class="devsite-nav-text" tooltip menu="Resources"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Resources"> </span> </span></li> </ul> <ul class="devsite-nav-responsive-tabs"> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Overview" track-name="overview" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Overview </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/tutorials_overview?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Tutorials" track-name="tutorials" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip menu="_book"> Tutorials </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="_book"> </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/get_started?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Guide" track-name="guide" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Guide </span> <span class="devsite-nav-icon material-icons" data-icon="forward"> </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/api_docs/python/tff?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: API" track-name="api" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> API </span> <span class="devsite-nav-icon material-icons" data-icon="forward"> </span> </a></li> </ul></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/community?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Community </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community"> <span class="devsite-nav-text" tooltip menu="Community"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Community"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/about?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Why TensorFlow" track-name="why tensorflow" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Why TensorFlow </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Why TensorFlow" track-name="why tensorflow"> <span class="devsite-nav-text" tooltip menu="Why TensorFlow"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Why TensorFlow"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: GitHub" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> GitHub </span> </a></li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/tutorials_overview?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/tutorials_overview" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/tutorials_overview"><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item devsite-nav-heading"> <div class="devsite-nav-title devsite-nav-title-no-path"><span class="devsite-nav-text" tooltip>Federated learning</span> </div></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/federated_learning_for_image_classification?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/federated_learning_for_image_classification" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/federated_learning_for_image_classification"><span class="devsite-nav-text" tooltip>Federated Learning for Image Classification</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/federated_learning_for_text_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/federated_learning_for_text_generation" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/federated_learning_for_text_generation"><span class="devsite-nav-text" tooltip>Federated Learning for Text Generation</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/tuning_recommended_aggregators?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/tuning_recommended_aggregators" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/tuning_recommended_aggregators"><span class="devsite-nav-text" tooltip>Tuning Recommended Aggregations for Learning</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/federated_reconstruction_for_matrix_factorization?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/federated_reconstruction_for_matrix_factorization" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/federated_reconstruction_for_matrix_factorization"><span class="devsite-nav-text" tooltip>Federated Reconstruction for Matrix Factorization</span></a></li> <li class="devsite-nav-item devsite-nav-heading"> <div class="devsite-nav-title devsite-nav-title-no-path"><span class="devsite-nav-text" tooltip>Federated analytics</span> </div></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/private_heavy_hitters?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/private_heavy_hitters" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/private_heavy_hitters"><span class="devsite-nav-text" tooltip>Private Heavy Hitters</span></a></li> <li class="devsite-nav-item devsite-nav-heading"> <div class="devsite-nav-title devsite-nav-title-no-path"><span class="devsite-nav-text" tooltip>Custom computations</span> </div></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/building_your_own_federated_learning_algorithm?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/building_your_own_federated_learning_algorithm" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/building_your_own_federated_learning_algorithm"><span class="devsite-nav-text" tooltip>Building Your Own Federated Learning Algorithm</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/composing_learning_algorithms?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/composing_learning_algorithms" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/composing_learning_algorithms"><span class="devsite-nav-text" tooltip>Composing Learning Algorithms</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/custom_federated_algorithms_1?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/custom_federated_algorithms_1" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/custom_federated_algorithms_1"><span class="devsite-nav-text" tooltip>Custom Federated Algorithms Part 1 - Introduction to the Federated Core</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/custom_federated_algorithms_2?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/custom_federated_algorithms_2" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/custom_federated_algorithms_2"><span class="devsite-nav-text" tooltip>Custom Federated Algorithms Part 2 - Implementing Federated Averaging</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/custom_aggregators?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/custom_aggregators" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/custom_aggregators"><span class="devsite-nav-text" tooltip>Implementing Custom Aggregators</span></a></li> <li class="devsite-nav-item devsite-nav-heading"> <div class="devsite-nav-title devsite-nav-title-no-path"><span class="devsite-nav-text" tooltip>Simulation Runtime</span> </div></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/simulations_with_accelerators?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/simulations_with_accelerators" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/simulations_with_accelerators"><span class="devsite-nav-text" tooltip>TFF Simulation with Accelerators (GPU)</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/working_with_client_data?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/working_with_client_data" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/working_with_client_data"><span class="devsite-nav-text" tooltip>Working with ClientData</span></a></li> <li class="devsite-nav-item devsite-nav-heading"> <div class="devsite-nav-title devsite-nav-title-no-path"><span class="devsite-nav-text" tooltip>Advanced tutorials</span> </div></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/random_noise_generation" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/random_noise_generation"><span class="devsite-nav-text" tooltip>Random Noise Generation</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/federated_select?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/federated_select" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/federated_select"><span class="devsite-nav-text" tooltip>Sending Different Data To Particular Clients With tff.federated_select</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/federated_learning_with_differential_privacy?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/federated_learning_with_differential_privacy" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/federated_learning_with_differential_privacy"><span class="devsite-nav-text" tooltip>Federated Learning with Differential Privacy in TFF</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/loading_remote_data?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/loading_remote_data" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/loading_remote_data"><span class="devsite-nav-text" tooltip>Loading Remote Data with TFF</span></a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/jax_support?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /federated/tutorials/jax_support" track-type="bookNav" track-name="click" track-metadata-eventdetail="/federated/tutorials/jax_support"><span class="devsite-nav-text" tooltip>Experimental support for JAX in TFF</span></a></li> </ul> <ul class="devsite-nav-list" menu="Learn" aria-label="Side menu" hidden> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/learn?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Introduction" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Introduction </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tutorials?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Tutorials" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Tutorials </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/guide?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Guide" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Guide </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/learn-ml?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Learn ML" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Learn ML </span> </a></li> </ul> <ul class="devsite-nav-list" menu="API" aria-label="Side menu" hidden> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/api/stable?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow (v2.16.1)" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TensorFlow (v2.16.1) </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/versions?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Versions…" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Versions… </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://js.tensorflow.org/api/latest/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow.js" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TensorFlow.js </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/lite/api_docs?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow Lite" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TensorFlow Lite </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tfx/api_docs?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TFX" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TFX </span> </a></li> </ul> <ul class="devsite-nav-list" menu="Resources" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> LIBRARIES </span> </span></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/js?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow.js" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TensorFlow.js </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/lite?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow Lite" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TensorFlow Lite </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/tfx?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TFX" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> TFX </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/libraries-extensions?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: All libraries" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> All libraries </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> RESOURCES </span> </span></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/models-datasets?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Models &amp; datasets" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Models &amp; datasets </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/tools?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Tools" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Tools </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/responsible_ai?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Responsible AI" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Responsible AI </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/resources/recommendation-systems?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Recommendation systems" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Recommendation systems </span> </a></li> </ul> <ul class="devsite-nav-list" menu="Community" aria-label="Side menu" hidden> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/community/groups?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Groups" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Groups </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/community/contribute?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Contribute" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Contribute </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://blog.tensorflow.org/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Blog" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Blog </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://discuss.tensorflow.org" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Forum" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Forum </span> </a></li> </ul> <ul class="devsite-nav-list" menu="Why TensorFlow" aria-label="Side menu" hidden> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/about?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: About" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> About </span> </a></li> <li class="devsite-nav-item"><a href="https://www-tensorflow-org.translate.goog/about/case-studies?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Case studies" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Case studies </span> </a></li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar> <div class="devsite-sidebar"> <div class="devsite-sidebar-content"><devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div><devsite-content> <article class="devsite-article"> <style> /* Styles inlined from /site-assets/css/style.css */ /* override theme */ table img { max-width: 100%; } /* .devsite-terminal virtualenv prompt */ .tfo-terminal-venv::before { content: "(venv) $ " !important; } /* .devsite-terminal root prompt */ .tfo-terminal-root::before { content: "# " !important; } /* Used in links for type annotations in function/method signatures */ .tfo-signature-link a, .tfo-signature-link a:visited, .tfo-signature-link a:hover, .tfo-signature-link a:focus, .tfo-signature-link a:hover *, .tfo-signature-link a:focus * { text-decoration: none !important; } .tfo-signature-link a, .tfo-signature-link a:visited { border-bottom: 1px dotted #1a73e8; } .tfo-signature-link a:focus { border-bottom-style: solid; } /* .devsite-terminal Windows prompt */ .tfo-terminal-windows::before { content: "C:\\> " !important; } /* .devsite-terminal Windows prompt w/ virtualenv */ .tfo-terminal-windows-venv::before { content: "(venv) C:\\> " !important; } .tfo-diff-green-one-level + * { background: rgba(175, 245, 162, .6) !important; } .tfo-diff-green + * > * { background: rgba(175, 245, 162, .6) !important; } .tfo-diff-green-list + ul > li:first-of-type { background: rgba(175, 245, 162, .6) !important; } .tfo-diff-red-one-level + * { background: rgba(255, 230, 230, .6) !important; text-decoration: line-through !important; } .tfo-diff-red + * > * { background: rgba(255, 230, 230, .6) !important; text-decoration: line-through !important; } .tfo-diff-red-list + ul > li:first-of-type { background: rgba(255, 230, 230, .6) !important; text-decoration: line-through !important; } devsite-code .tfo-notebook-code-cell-output { max-height: 300px; overflow: auto; background: rgba(255, 247, 237, 1); /* orange bg to distinguish from input code cells */ } devsite-code .tfo-notebook-code-cell-output + .devsite-code-buttons-container button { background: rgba(255, 247, 237, .7); /* orange bg to distinguish from input code cells */ } devsite-code[dark-code] .tfo-notebook-code-cell-output { background: rgba(64, 78, 103, 1); /* medium slate */ } devsite-code[dark-code] .tfo-notebook-code-cell-output + .devsite-code-buttons-container button { background: rgba(64, 78, 103, .7); /* medium slate */ } /* override default table styles for notebook buttons */ .devsite-table-wrapper .tfo-notebook-buttons { display: inline-block; margin-left: 3px; width: auto; } .tfo-notebook-buttons td { padding-left: 0; padding-right: 20px; } .tfo-notebook-buttons a, .tfo-notebook-buttons :link, .tfo-notebook-buttons :visited { border-radius: 8px; box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15); color: #202124; padding: 12px 17px; transition: box-shadow 0.2s; } .tfo-notebook-buttons a:hover, .tfo-notebook-buttons a:focus { box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 2px 6px 2px rgba(60, 64, 67, .15); } .tfo-notebook-buttons tr { background: 0; border: 0; } /* on rendered notebook page, remove link to webpage since we're already here */ .tfo-notebook-buttons:not(.tfo-api) td:first-child { display: none; } .tfo-notebook-buttons td > a { -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -ms-flexbox; display: flex; } .tfo-notebook-buttons td > a > img { margin-right: 8px; } /* landing pages */ .tfo-landing-row-item-inset-white { background-color: #fff; padding: 32px; } .tfo-landing-row-item-inset-white ol, .tfo-landing-row-item-inset-white ul { padding-left: 20px; } /* colab callout button */ .colab-callout-row devsite-code { border-radius: 8px 8px 0 0; box-shadow: none; } .colab-callout-footer { background: #e3e4e7; border-radius: 0 0 8px 8px; color: #37474f; padding: 20px; } .colab-callout-row devsite-code[dark-code] + .colab-callout-footer { background: #3f4f66; } .colab-callout-footer > .button { margin-top: 4px; color: #ff5c00; } .colab-callout-footer > a > span { vertical-align: middle; color: #37474f; padding-left: 10px; font-size: 14px; } .colab-callout-row devsite-code[dark-code] + .colab-callout-footer > a > span { color: #fff; } a.colab-button { background: rgba(255, 255, 255, .75); border: solid 1px rgba(0, 0, 0, .08); border-bottom-color: rgba(0, 0, 0, .15); border-radius: 4px; color: #aaa; display: inline-block; font-size: 11px !important; font-weight: 300; line-height: 16px; padding: 4px 8px; text-decoration: none; text-transform: uppercase; } a.colab-button:hover { background: white; border-color: rgba(0, 0, 0, .2); color: #666; } a.colab-button span { background: url(/images/colab_logo_button.svg) no-repeat 1px 1px / 20px; border-radius: 4px; display: inline-block; padding-left: 24px; text-decoration: none; } @media screen and (max-width: 600px) { .tfo-notebook-buttons td { display: block; } } /* guide and tutorials landing page cards and sections */ .tfo-landing-page-card { padding: 16px; box-shadow: 0 0 36px rgba(0,0,0,0.1); border-radius: 10px; } /* Page section headings */ .tfo-landing-page-heading h2, h2.tfo-landing-page-heading { font-family: "Google Sans", sans-serif; color: #425066; font-size: 30px; font-weight: 700; line-height: 40px; } /* Item title headings */ .tfo-landing-page-heading h3, h3.tfo-landing-page-heading, .tfo-landing-page-card h3, h3.tfo-landing-page-card { font-family: "Google Sans", sans-serif; color: #425066; font-size: 20px; font-weight: 500; line-height: 26px; } /* List of tutorials notebooks for subsites */ .tfo-landing-page-resources-ul { padding-left: 15px } .tfo-landing-page-resources-ul > li { margin: 6px 0; } /* Temporary fix to hide product description in header on landing pages */ devsite-header .devsite-product-description { display: none; } </style> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "><a href="https://www-tensorflow-org.translate.goog/?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="TensorFlow"> TensorFlow </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://www-tensorflow-org.translate.goog/resources?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail=""> Resources </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://www-tensorflow-org.translate.goog/federated?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="TensorFlow Federated"> Federated </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://www-tensorflow-org.translate.goog/federated/tutorials/tutorials_overview?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="4" track-type="globalNav" track-name="breadcrumb" track-metadata-position="4" track-metadata-eventdetail=""> Tutorials </a></li> </ul><devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <h1 class="devsite-page-title" tabindex="-1">Random noise generation in TFF</h1><devsite-feature-tooltip ack-key="AckCollectionsBookmarkTooltipDismiss" analytics-category="Site-Wide Custom Events" analytics-action-show="Callout Profile displayed" analytics-action-close="Callout Profile dismissed" analytics-label="Create Collection Callout" class="devsite-page-bookmark-tooltip nocontent" dismiss-button="true" id="devsite-collections-dropdown" dismiss-button-text="Dismiss" close-button-text="Got it"> <devsite-bookmark></devsite-bookmark> <span slot="popout-heading"> Stay organized with collections </span> <span slot="popout-contents"> Save and categorize content based on your preferences. </span> </devsite-feature-tooltip> <div class="devsite-page-title-meta"> <devsite-view-release-notes></devsite-view-release-notes> </div><devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded> </devsite-toc> <div class="devsite-article-body clearfix "> <p></p><!-- DO NOT EDIT! Automatically generated file. --> <div itemscope itemtype="http://developers.google.com/ReferenceObject"> <meta itemprop="name" content="Random noise generation in TFF"> <meta itemprop="path" content="Guide &amp; Tutorials"> <meta itemprop="property" content="tff.backends.native.set_sync_local_cpp_execution_context"> <meta itemprop="property" content="tff.federated_broadcast"> <meta itemprop="property" content="tff.federated_computation"> <meta itemprop="property" content="tff.federated_eval"> <meta itemprop="property" content="tff.federated_map"> <meta itemprop="property" content="tff.federated_max"> <meta itemprop="property" content="tff.federated_min"> <meta itemprop="property" content="tff.learning.models.ModelWeights"> <meta itemprop="property" content="tff.tensorflow.computation"> <meta itemprop="property" content="tff.types.FederatedType"> <meta itemprop="property" content="tff.types.to_type"> </div> <p>This tutorial will discuss the recommended best practices for random noise generation in TFF. Random noise generation is an important component of many privacy protection techniques in federated learning algorithms, e.g., differential privacy.</p> <table class="tfo-notebook-buttons" align="left"> <tbody> <tr> <td><a target="_blank" href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><img src="https://www.tensorflow.org/images/tf_logo_32px.png">View on TensorFlow.org</a></td> <td><a target="_blank" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://colab.research.google.com/github/tensorflow/federated/blob/v0.88.0/docs/tutorials/random_noise_generation.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png">Run in Google Colab</a></td> <td><a target="_blank" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/federated/blob/v0.88.0/docs/tutorials/random_noise_generation.ipynb"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png">View source on GitHub</a></td> <td><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://storage.googleapis.com/tensorflow_docs/federated/docs/tutorials/random_noise_generation.ipynb"><img src="https://www.tensorflow.org/images/download_logo_32px.png">Download notebook</a></td> </tr> </tbody> </table> <h2 id="before_we_begin" data-text="Before we begin" tabindex="-1">Before we begin</h2> <p>First, let us make sure the notebook is connected to a backend that has the relevant components compiled.</p> <pre class="prettyprint lang-bsh" translate="no" dir="ltr"><code class="devsite-terminal" translate="no" dir="ltr">pip install --quiet --upgrade tensorflow-federated</code> </pre> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">import numpy as np import tensorflow as tf import tensorflow_federated as tff </code></pre> <p>Run the following "Hello World" example to make sure the TFF environment is correctly setup. If it doesn't work, please refer to the <a href="https://www-tensorflow-org.translate.goog/federated/install?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB">Installation</a> guide for instructions.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">@tff.federated_computation def hello_world(): return 'Hello, World!' hello_world() </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">b'Hello, World!' </pre> <h2 id="random_noise_on_clients" data-text="Random noise on clients" tabindex="-1">Random noise on clients</h2> <p>The need for noise on clients generally falls into two cases: identical noise and i.i.d. noise.</p> <ul> <li>For identical noise, the recommended pattern is to maintain a seed on the server, broadcast it to clients, and use the <code translate="no" dir="ltr">tf.random.stateless</code> functions to generate noise.</li> <li>For i.i.d. noise, use a tf.random.Generator initialized on the client with from_non_deterministic_state, in keeping with TF's recommendation to avoid the tf.random.&lt;distribution&gt; functions.</li> </ul> <p>Client behavior is different from server (doesn't suffer from the pitfalls discussed later) because each client will build their own computation graph and initialize their own default seed.</p> <h3 id="identical_noise_on_clients" data-text="Identical noise on clients" tabindex="-1">Identical noise on clients</h3> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr"># Set to use 10 clients. tff.backends.native.set_sync_local_cpp_execution_context(default_num_clients=10) @tff.tensorflow.computation def noise_from_seed(seed): return tf.random.stateless_normal((), seed=seed) seed_type_at_server = tff.FederatedType(tff.to_type((np.int64, [2])), tff.SERVER) @tff.federated_computation(seed_type_at_server) def get_random_min_and_max_deterministic(seed): # Broadcast seed to all clients. seed_on_clients = tff.federated_broadcast(seed) # Clients generate noise from seed deterministicly. noise_on_clients = tff.federated_map(noise_from_seed, seed_on_clients) # Aggregate and return the min and max of the values generated on clients. min = tff.federated_min(noise_on_clients) max = tff.federated_max(noise_on_clients) return min, max seed = tf.constant([1, 1], dtype=tf.int64) min, max = get_random_min_and_max_deterministic(seed) assert min == max print(f'Seed: {seed.numpy()}. All clients sampled value {min:8.3f}.') seed += 1 min, max = get_random_min_and_max_deterministic(seed) assert min == max print(f'Seed: {seed.numpy()}. All clients sampled value {min:8.3f}.') </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">Seed: [1 1]. All clients sampled value 1.665. Seed: [2 2]. All clients sampled value -0.219. </pre> <h3 id="independent_noise_on_clients" data-text="Independent noise on clients" tabindex="-1">Independent noise on clients</h3> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">@tff.tensorflow.computation def nondeterministic_noise(): gen = tf.random.Generator.from_non_deterministic_state() return gen.normal(()) @tff.federated_computation def get_random_min_and_max_nondeterministic(): noise_on_clients = tff.federated_eval(nondeterministic_noise, tff.CLIENTS) min = tff.federated_min(noise_on_clients) max = tff.federated_max(noise_on_clients) return min, max min, max = get_random_min_and_max_nondeterministic() assert min != max print(f'Values differ across clients. {min:8.3f},{max:8.3f}.') new_min, new_max = get_random_min_and_max_nondeterministic() assert new_min != new_max assert new_min != min and new_max != max print(f'Values differ across rounds. {new_min:8.3f},{new_max:8.3f}.') </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">Values differ across clients. -1.490, 1.172. Values differ across rounds. -1.358, 1.208. </pre> <h3 id="model_initializer_on_clients" data-text="Model initializer on clients" tabindex="-1">Model initializer on clients</h3> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">def _keras_model(): inputs = tf.keras.Input(shape=(1,)) outputs = tf.keras.layers.Dense(1)(inputs) return tf.keras.Model(inputs=inputs, outputs=outputs) @tff.tensorflow.computation def tff_return_model_init(): model = _keras_model() # return the initialized single weight value of the dense layer return tf.reshape( tff.learning.models.ModelWeights.from_model(model).trainable[0], [-1])[0] @tff.federated_computation def get_random_min_and_max_nondeterministic(): noise_on_clients = tff.federated_eval(tff_return_model_init, tff.CLIENTS) min = tff.federated_min(noise_on_clients) max = tff.federated_max(noise_on_clients) return min, max min, max = get_random_min_and_max_nondeterministic() assert min != max print(f'Values differ across clients. {min:8.3f},{max:8.3f}.') new_min, new_max = get_random_min_and_max_nondeterministic() assert new_min != new_max assert new_min != min and new_max != max print(f'Values differ across rounds. {new_min:8.3f},{new_max:8.3f}.') </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">Values differ across clients. -1.022, 1.567. Values differ across rounds. -1.675, 1.550. </pre> <h2 id="random_noise_on_the_server" data-text="Random noise on the server" tabindex="-1">Random noise on the server</h2> <h3 id="discouraged_usage_directly_using_tfrandomnormal" data-text="Discouraged usage: directly using tf.random.normal" tabindex="-1">Discouraged usage: directly using <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/normal?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.normal</code></a></h3> <p>TF1.x like APIs <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/normal?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.normal</code></a> for random noise generation are strongly discouraged in TF2 according to the <a href="https://www-tensorflow-org.translate.goog/guide/random_numbers?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB">random noise generation tutorial in TF</a>. Surprising behavior may happen when these APIs are used together with <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/function?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.function</code></a> and <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/set_seed?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.set_seed</code></a>. For example, the following code will generate the same value with each call. This surprising behavior is expected for TF, and explanation can be found in the <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/set_seed?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB">documentation of <code translate="no" dir="ltr">tf.random.set_seed</code></a>.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">tf.random.set_seed(1) @tf.function def return_one_noise(_): return tf.random.normal([]) n1=return_one_noise(1) n2=return_one_noise(2) assert n1 == n2 print(n1.numpy(), n2.numpy()) </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">0.3052047 0.3052047 </pre> <p>In TFF, things are slightly different. If we wrap the noise generation as <a href="https://www-tensorflow-org.translate.goog/federated/api_docs/python/tff/tensorflow/computation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tff.tensorflow.computation</code></a> instead of <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/function?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.function</code></a>, non-deterministic random noise will be generated. However, if we run this code snippet multiple times, different set of <code translate="no" dir="ltr">(n1, n2)</code> will be generated each time. There is no easy way to set a global random seed for TFF.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">tf.random.set_seed(1) @tff.tensorflow.computation def return_one_noise(_): return tf.random.normal([]) n1=return_one_noise(1) n2=return_one_noise(2) assert n1 != n2 print(n1, n2) </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">0.11990704 1.9185987 </pre> <p>Moreover, deterministic noise can be generated in TFF without explicitly setting a seed. The function <code translate="no" dir="ltr">return_two_noise</code> in the following code snippet returns two identical noise values. This is expected behavior because TFF will build computation graph in advance before execution. However, this suggests users have to pay attention on the usage of <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/normal?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.normal</code></a> in TFF.</p> <h3 id="usage_with_care_tfrandomgenerator" data-text="Usage with care: tf.random.Generator" tabindex="-1">Usage with care: <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/Generator?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.Generator</code></a></h3> <p>We can use <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/Generator?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.Generator</code></a> as suggested in the <a href="https://www-tensorflow-org.translate.goog/guide/random_numbers?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB">TF tutorial</a>.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">@tff.tensorflow.computation def tff_return_one_noise(i): g=tf.random.Generator.from_seed(i) @tf.function def tf_return_one_noise(): return g.normal([]) return tf_return_one_noise() @tff.federated_computation def return_two_noise(): return (tff_return_one_noise(1), tff_return_one_noise(2)) n1, n2 = return_two_noise() assert n1 != n2 print(n1, n2) </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">0.3052047 -0.38260335 </pre> <p>However, users may have to be careful on its usage</p> <ul> <li><a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/Generator?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.Generator</code></a> uses <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/Variable?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.Variable</code></a> to maintain the states for RNG algorithms. In TFF, it is recommended to construct the generator inside a <a href="https://www-tensorflow-org.translate.goog/federated/api_docs/python/tff/tensorflow/computation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tff.tensorflow.computation</code></a>; and it is difficult to pass the generator and its state between <a href="https://www-tensorflow-org.translate.goog/federated/api_docs/python/tff/tensorflow/computation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tff.tensorflow.computation</code></a> functions.</li> <li>the previous code snippet also relies on carefully setting seeds in generators. We may get expected but surprising results (deterministic <code translate="no" dir="ltr">n1==n2</code>) if we use <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/Generator?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#from_non_deterministic_state"><code translate="no" dir="ltr">tf.random.Generator.from_non_deterministic_state()</code></a> instead.</li> </ul> <p>In general, TFF prefers functional operations and we will showcase the usage of <code translate="no" dir="ltr">tf.random.stateless_*</code> functions in the following sections.</p> <p>In TFF for federated learning, we often work with nested structures instead of scalars and the previous code snippet can be naturally extended to nested structures.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">@tff.tensorflow.computation def tff_return_one_noise(i): g=tf.random.Generator.from_seed(i) weights = [ tf.ones([2, 2], dtype=tf.float32), tf.constant([2], dtype=tf.float32) ] @tf.function def tf_return_one_noise(): return tf.nest.map_structure(lambda x: g.normal(tf.shape(x)), weights) return tf_return_one_noise() @tff.federated_computation def return_two_noise(): return (tff_return_one_noise(1), tff_return_one_noise(2)) n1, n2 = return_two_noise() assert n1[1] != n2[1] print('n1', n1) print('n2', n2) </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">n1 [array([[0.3052047 , 0.5671378 ], [0.41852272, 0.2326421 ]], dtype=float32), array([1.1675092], dtype=float32)] n2 [array([[-0.38260335, -0.4780486 ], [-0.5187485 , -1.8471988 ]], dtype=float32), array([-0.77835274], dtype=float32)] </pre> <h3 id="recommended_usage_tfrandomstateless_with_a_helper" data-text="Recommended usage: tf.random.stateless_* with a helper" tabindex="-1">Recommended usage: <code translate="no" dir="ltr">tf.random.stateless_*</code> with a helper</h3> <p>A general recommendation in TFF is to use the functional <code translate="no" dir="ltr">tf.random.stateless_*</code> functions for random noise generation. These functions take <code translate="no" dir="ltr">seed</code> (a Tensor with shape <code translate="no" dir="ltr">[2]</code> or a <code translate="no" dir="ltr">tuple</code> of two scalar tensors) as an explicit input argument to generate random noise. We first define a helper class to maintain the seed as pseudo state. The helper <code translate="no" dir="ltr">RandomSeedGenerator</code> has functional operators in a state-in-state-out fashion. It is reasonable to use a counter as pseudo state for <code translate="no" dir="ltr">tf.random.stateless_*</code> as these functions <a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/tensorflow/blob/919f693420e35d00c8d0a42100837ae3718f7927/tensorflow/core/kernels/stateless_random_ops.cc%23L50-L64">scramble</a> the seed before using it to make noises generated by correlated seeds statistically uncorrelated.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">def timestamp_seed(): # tf.timestamp returns microseconds as decimal places, thus scaling by 1e6. return tf.cast(tf.timestamp() * 1e6, tf.int64) class RandomSeedGenerator(): def initialize(self, seed=None): if seed is None: return tf.stack([timestamp_seed(), 0]) else: return tf.constant(self.seed, dtype=tf.int64, shape=(2,)) def next(self, state): return state + tf.constant([0, 1], tf.int64) def structure_next(self, state, nest_structure): "Returns seed in nested structure and the next state seed." flat_structure = tf.nest.flatten(nest_structure) flat_seeds = [state + tf.constant([0, i], tf.int64) for i in range(len(flat_structure))] nest_seeds = tf.nest.pack_sequence_as(nest_structure, flat_seeds) return nest_seeds, flat_seeds[-1] + tf.constant([0, 1], tf.int64) </code></pre> <p>Now let us use the helper class and <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/random/stateless_normal?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.random.stateless_normal</code></a> to generate (nested structure of) random noise in TFF. The following code snippet looks a lot like a TFF iterative process, see <a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/federated/blob/main/examples/simple_fedavg/simple_fedavg_tff.py">simple_fedavg</a> as an example of expressing federated learning algorithm as TFF iterative process. The pseudo seed state here for random noise generation is <a href="https://www-tensorflow-org.translate.goog/api_docs/python/tf/Tensor?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB"><code translate="no" dir="ltr">tf.Tensor</code></a> that can be easily transported in TFF and TF functions.</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">@tff.tensorflow.computation def tff_return_one_noise(seed_state): g=RandomSeedGenerator() weights = [ tf.ones([2, 2], dtype=tf.float32), tf.constant([2], dtype=tf.float32) ] @tf.function def tf_return_one_noise(): nest_seeds, updated_state = g.structure_next(seed_state, weights) nest_noise = tf.nest.map_structure(lambda x,s: tf.random.stateless_normal( shape=tf.shape(x), seed=s), weights, nest_seeds) return nest_noise, updated_state return tf_return_one_noise() @tff.tensorflow.computation def tff_init_state(): g=RandomSeedGenerator() return g.initialize() @tff.federated_computation def return_two_noise(): seed_state = tff_init_state() n1, seed_state = tff_return_one_noise(seed_state) n2, seed_state = tff_return_one_noise(seed_state) return (n1, n2) n1, n2 = return_two_noise() assert n1[1] != n2[1] print('n1', n1) print('n2', n2) </code></pre> <pre class="tfo-notebook-code-cell-output" translate="no" dir="ltr">n1 [array([[ 0.86828816, 0.8535084 ], [ 1.0053564 , -0.42096713]], dtype=float32), array([0.18048067], dtype=float32)] n2 [array([[-1.1973879 , -0.2974589 ], [ 1.8309833 , 0.17024393]], dtype=float32), array([0.68991095], dtype=float32)] </pre> </div><devsite-thumb-rating position="footer"> </devsite-thumb-rating> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Except as otherwise noted, the content of this page is licensed under the <a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 License</a>, and code samples are licensed under the <a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>. For details, see the <a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://developers.google.com/site-policies">Google Developers Site Policies</a>. Java is a registered trademark of Oracle and/or its affiliates.</p> <p>Last updated 2024-11-02 UTC.</p> </devsite-content-footer> <devsite-notification> </devsite-notification> <div class="devsite-content-data"> <template class="devsite-content-data-template"> [[["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 2024-11-02 UTC."],[],[]] </template> </div> </devsite-content> </main><devsite-footer-promos class="devsite-footer"> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> <ul class="devsite-footer-linkboxes-list"> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Stay connected</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://blog.tensorflow.org" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Blog </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://discuss.tensorflow.org" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Forum </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> GitHub </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://twitter.com/tensorflow" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Twitter </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://youtube.com/tensorflow" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> YouTube </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Support</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/tensorflow/issues" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Issue tracker </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Release notes </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://stackoverflow.com/questions/tagged/tensorflow" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> Stack Overflow </a></li> <li class="devsite-footer-linkbox-item"><a href="https://www-tensorflow-org.translate.goog/extras/tensorflow_brand_guidelines.pdf?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Brand guidelines </a></li> <li class="devsite-footer-linkbox-item"><a href="https://www-tensorflow-org.translate.goog/about/bib?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> Cite TensorFlow </a></li> </ul></li> </ul> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "><a class="devsite-footer-utility-link gc-analytics-event" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://policies.google.com/terms" data-category="Site-Wide Custom Events" data-label="Footer Terms link"> Terms </a></li> <li class="devsite-footer-utility-item "><a class="devsite-footer-utility-link gc-analytics-event" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link"> Privacy </a></li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"><a class="devsite-footer-utility-link gc-analytics-event" href="https://www-tensorflow-org.translate.goog/federated/tutorials/random_noise_generation?_x_tr_sl=pl&amp;_x_tr_tl=cs&amp;_x_tr_hl=en-GB#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true"> Manage cookies </a></li> <li class="devsite-footer-utility-item devsite-footer-utility-button"><span class="devsite-footer-utility-description">Sign up for the TensorFlow newsletter</span> <a class="devsite-footer-utility-link gc-analytics-event" href="https://translate.google.com/website?sl=pl&amp;tl=cs&amp;hl=en-GB&amp;u=https://www.tensorflow.org/subscribe" data-category="Site-Wide Custom Events" data-label="Footer Subscribe link"> Subscribe </a></li> </ul><devsite-language-selector> <ul role="presentation"> <li role="presentation"><a role="menuitem" lang="en">English</a></li> <li role="presentation"><a role="menuitem" lang="es_419">Español – América Latina</a></li> <li role="presentation"><a role="menuitem" lang="fr">Français</a></li> <li role="presentation"><a role="menuitem" lang="id">Indonesia</a></li> <li role="presentation"><a role="menuitem" lang="it">Italiano</a></li> <li role="presentation"><a role="menuitem" lang="pl">Polski</a></li> <li role="presentation"><a role="menuitem" lang="pt_br">Português – Brasil</a></li> <li role="presentation"><a role="menuitem" lang="vi">Tiếng Việt</a></li> <li role="presentation"><a role="menuitem" lang="tr">Türkçe</a></li> <li role="presentation"><a role="menuitem" lang="ru">Русский</a></li> <li role="presentation"><a role="menuitem" lang="he">עברית</a></li> <li role="presentation"><a role="menuitem" lang="ar">العربيّة</a></li> <li role="presentation"><a role="menuitem" lang="fa">فارسی</a></li> <li role="presentation"><a role="menuitem" lang="hi">हिंदी</a></li> <li role="presentation"><a role="menuitem" lang="bn">বাংলা</a></li> <li role="presentation"><a role="menuitem" lang="th">ภาษาไทย</a></li> <li role="presentation"><a role="menuitem" lang="zh_cn">中文 – 简体</a></li> <li role="presentation"><a role="menuitem" lang="ja">日本語</a></li> <li role="presentation"><a role="menuitem" lang="ko">한국어</a></li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section> </section><devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[{&#34;dimensions&#34;: {&#34;dimension12&#34;: false, &#34;dimension3&#34;: false, &#34;dimension1&#34;: &#34;Signed out&#34;, &#34;dimension4&#34;: &#34;TensorFlow Federated&#34;, &#34;dimension6&#34;: &#34;en&#34;, &#34;dimension5&#34;: &#34;en&#34;}, &#34;gaid&#34;: &#34;UA-69864048-1&#34;, &#34;metrics&#34;: {&#34;ratings_count&#34;: &#34;metric2&#34;, &#34;ratings_value&#34;: &#34;metric1&#34;}, &#34;purpose&#34;: 0}]</script> <script type="application/json" tag-management>{&#34;at&#34;: &#34;True&#34;, &#34;ga4&#34;: [], &#34;ga4p&#34;: [], &#34;gtm&#34;: [{&#34;id&#34;: &#34;GTM-MXSL34P&#34;, &#34;purpose&#34;: 0}], &#34;parameters&#34;: {&#34;internalUser&#34;: &#34;False&#34;, &#34;language&#34;: {&#34;machineTranslated&#34;: &#34;False&#34;, &#34;requested&#34;: &#34;en&#34;, &#34;served&#34;: &#34;en&#34;}, &#34;pageType&#34;: &#34;article&#34;, &#34;projectName&#34;: &#34;TensorFlow Federated&#34;, &#34;signedIn&#34;: &#34;False&#34;, &#34;tenant&#34;: &#34;tensorflow&#34;, &#34;recommendations&#34;: {&#34;sourcePage&#34;: &#34;&#34;, &#34;sourceType&#34;: 0, &#34;sourceRank&#34;: 0, &#34;sourceIdenticalDescriptions&#34;: 0, &#34;sourceTitleWords&#34;: 0, &#34;sourceDescriptionWords&#34;: 0, &#34;experiment&#34;: &#34;&#34;}, &#34;experiment&#34;: {&#34;ids&#34;: &#34;&#34;}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <script nonce="y0uqYG5Fke8HGSFPC9zDqfQ9Qb7Yf7"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/js/app_loader.js', '[15,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow","https://tensorflow-dot-devsite-v2-prod-3p.appspot.com",null,null,["/_pwa/tensorflow/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/favicon.png","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/tensorflow/images/lockup.svg","https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyCNm9YxQumEXwGJgTDjxoxXK6m1F-9720Q","AIzaSyCc76DZePGtoyUjqKrLdsMGk_ry7sljLbY","www.tensorflow.org","AIzaSyB9bqgQ2t11WJsOX8qNsCQ6U-w91mmqF-I","AIzaSyAdYnStPdzjcJJtQ0mvIaeaMKj7_t6J_Fg",null,null,null,["Profiles__require_profile_eligibility_for_signin","Cloud__enable_legacy_calculator_redirect","EngEduTelemetry__enable_engedu_telemetry","TpcFeatures__enable_required_headers","Profiles__enable_complete_playlist_endpoint","MiscFeatureFlags__enable_view_transitions","Cloud__enable_cloud_shell_fte_user_flow","MiscFeatureFlags__developers_footer_dark_image","SignIn__enable_refresh_access_tokens","Cloud__enable_cloud_shell","Experiments__reqs_query_experiments","DevPro__enable_developer_subscriptions","Profiles__enable_dashboard_curated_recommendations","CloudShell__cloud_code_overflow_menu","Cloud__enable_cloudx_ping","CloudShell__cloud_shell_button","Search__enable_suggestions_from_borg","Profiles__enable_completecodelab_endpoint","Cloud__enable_free_trial_server_call","Concierge__enable_pushui","Analytics__enable_clearcut_logging","MiscFeatureFlags__enable_variable_operator","Profiles__enable_release_notes_notifications","Search__enable_page_map","Profiles__enable_profile_collections","MiscFeatureFlags__enable_project_variables","BookNav__enable_tenant_cache_key","Cloud__enable_cloudx_experiment_ids","TpcFeatures__enable_mirror_tenant_redirects","Profiles__enable_awarding_url","MiscFeatureFlags__developers_footer_image","Profiles__enable_public_developer_profiles","Profiles__enable_recognition_badges","Cloud__enable_cloud_dlp_service","Search__enable_dynamic_content_confidential_banner","DevPro__enable_cloud_innovators_plus","Cloud__enable_llm_concierge_chat","MiscFeatureFlags__emergency_css","Profiles__enable_developer_profiles_callout","MiscFeatureFlags__enable_firebase_utm","Cloud__enable_cloud_facet_chat","Profiles__enable_page_saving","Search__enable_ai_eligibility_checks"],null,null,"AIzaSyA58TaKli1DculwmAmbpzLVGuWc8eCQgQc","https://developerscontentserving-pa.googleapis.com","AIzaSyDWBU60w0P9hEkr29kkksYs8Z7gvZ8u_wc","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[15,"tensorflow","TensorFlow","www.tensorflow.org",null,"tensorflow-dot-devsite-v2-prod-3p.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],[1,null,null,[1]],null,null,null,[1,null,1],[1,1,null,1,1]],null,[25,null,null,null,null,null,"/images/lockup.svg","/images/logo.png",null,null,null,1,1,null,null,null,null,null,null,null,null,1,null,null,null,null,[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[6,1],null,[[],[1,1]],[[["UA-69864048-1"],["UA-69864048-4"],null,null,["UA-69864048-5"],["GTM-MXSL34P"],null,null,[["UA-69864048-1",1]],null,[["UA-69864048-5",1]],[["GTM-MXSL34P",1]],1],[[1,1],[5,4],[6,5],[12,8],[3,2],[4,3]],[[1,1],[2,2]]],null,4],1]') </script><devsite-a11y-announce></devsite-a11y-announce> <script>function gtElInit() {var lib = new google.translate.TranslateService();lib.translatePage('pl', 'cs', function () {});}</script> <script src="https://translate.google.com/translate_a/element.js?cb=gtElInit&amp;hl=en-GB&amp;client=wt" type="text/javascript"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10