天天看点

tensorflow Federated: 本地模型训练,无需上传训练数据

google 刚发布了 TFF 框架,全名是 TensorFlow Federated,它是干什么的呢,可以大概总结下:

边缘设备(比如:手机)在本地 利用本地数据 训练模型,进而把 本地训练的模型参数 上传服务器,然后 服务器对 各个边缘设备 上传 的模型参数进行 聚合。

为什么 需要这样做呢? 

目前大家 主要的 做法是 把 各种数据收集至 server,然后 利用 汇总的 数据进行模型训练,但是 在 手机数据时,大家可能 会遇到 一些 敏感信息 不能收集或者收集困难的 问题,这可能 会导致 最终模型 的 性能 受到影响。

而TFF的出现,解决了这种敏感信息 上传 的问题。

下面是对 TFF的说明

原文地址:https://medium.com/tensorflow/introducing-tensorflow-federated-a4147aa20041?linkId=64497175

Introducing TensorFlow Federated

Posted by Alex Ingerman (Product Manager) and Krzys Ostrowski (Research Scientist)

There are an estimated 3 billion smartphones in the world, and 7 billion connected devices. These phones and devices are constantly generating new data. Traditional analytics and machine learning need that data to be centrally collected before it is processed to yield insights, ML models and ultimately better products. This centralized approach can be problematic if the data is sensitive or expensive to centralize. Wouldn’t it be better if we could run the data analysis and machine learning right on the devices where that data is generated, and still be able to aggregate together what’s been learned?

TensorFlow Federated (TFF) is an open source framework for experimenting with machine learning and other computations on decentralized data. It implements an approach called Federated Learning (FL), which enables many participating clients to train shared ML models, while keeping their data locally. We have designed TFF based on our experiences with developing the federated learning technology at Google, where it powers ML models for mobile keyboard predictions and on-device search. With TFF, we are excited to put a flexible, open framework for locally simulating decentralized computations into the hands of all TensorFlow users.

tensorflow Federated: 本地模型训练,无需上传训练数据

To illustrate the use of FL and TFF, let’s start with one of the most famous image datasets: MNIST. The original NIST dataset, from which MNIST was created, contains images of 810,000 handwritten digits, collected from 3,600 volunteers — and our task is to build an ML model that will recognize the digits. The traditional way we’d go about it is to apply an ML algorithm to the entire dataset at once. But what if we couldn’t combine all that data together — for example, because the volunteers did not agree to uploading their raw data to a central server?

With TFF, we can express an ML model architecture of our choice, and then train it across data provided by all writers, while keeping each writer’s data separate and local. We show how to do that below with TFF’s Federated Learning (FL) API, using a version of the NIST dataset that has been processed by the Leaf project to separate the digits written by each volunteer.

tensorflow Federated: 本地模型训练,无需上传训练数据

You can see the rest in the federated MNIST classifications tutorial.

In addition to the FL API, TFF comes with a set of lower-level primitives, which we call the Federated Core (FC) API. This API enables the expression of a broad range of computations over a decentralized dataset. Training an ML model with federated learning is one example of a federated computation; evaluating it over decentralized data is another.

Let’s take a look at the FC API with a simple example. Suppose we have an array of sensors capturing temperature readings, and want to compute the average temperature across these sensors, without uploading their data to a central location. With FC API, we can express a new data type, specifying its underlying data (

tf.float32

) and where that data lives (on distributed clients).

tensorflow Federated: 本地模型训练,无需上传训练数据

And then specify a federated average function over that type.

tensorflow Federated: 本地模型训练,无需上传训练数据

After the federated computation is defined, TFF represents it in a form that could be run in a decentralized setting. TFF’s initial release includes a local-machine runtime that simulates the computation being executed across a set of clients holding the data, with each client computing their local contribution, and the centralized coordinator aggregating all the contributions. From the developer’s perspective, though, the federated computation can be seen as an ordinary function, that happens to have inputs and outputs that reside in different places (on individual clients and in the coordinating service, respectively).

tensorflow Federated: 本地模型训练,无需上传训练数据

Expressing a simple variant of the Federated Averaging algorithm is also straightforward using TFF’s declarative model:

tensorflow Federated: 本地模型训练,无需上传训练数据

With TensorFlow Federated, we are taking a step towards making the technology accessible to a wider audience, and inviting community participation in developing federated learning research on top of an open, flexible platform. You can try out TFF in your browser, with just a few clicks, by walking through the tutorials. There are many ways to get involved: you can experiment with existing FL algorithms on your models, contribute new federated datasets and models to the TFF repository, add implementations of new FL algorithms, or extend existing ones with new features.

Over time, we’d like TFF runtimes to become available for the major device platforms, and to integrate other technologies that help protect sensitive user data, including differential privacy for federated learning (integrating with TensorFlow Privacy) and secure aggregation. We look forward to developing TFF together with the community, and enabling every developer to use federated technologies.

Ready to get started? Please visit https://www.tensorflow.org/federated/ and try out TFF today!

Acknowledgments

Creating TensorFlow Federated was a team effort. Special thanks to Brendan McMahan, Keith Rush, Michael Reneer, and Zachary Garrett, who all made significant contributions.

也可以关注我的知乎和微信公众号

知乎: https://zhuanlan.zhihu.com/albertwang

微信公众号:AI-Research-Studio

tensorflow Federated: 本地模型训练,无需上传训练数据
tensorflow Federated: 本地模型训练,无需上传训练数据

下面是赞赏码

tensorflow Federated: 本地模型训练,无需上传训练数据
tensorflow Federated: 本地模型训练,无需上传训练数据

继续阅读