/tf-world-tutorial

TensorFlow World 2019 Tutorial: Privacy-Preserving Machine Learning with TF Encrypted & PySyft

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

TensorFlow World: Privacy-Preserving Machine Learning with TensorFlow

Disclaimer: please note that the installation instructions will be updated until October 22nd and the tutorial until October 28th.

In this tutorial, you will learn how to build and deploy privacy-preserving machine learning models using TF Encrypted, PySyft-TensorFlow, and the TensorFlow ecosystem.

This tutorial was created for the TensorFlow World conference on Tuesday, October the 29th 2019 at 1:30pm PST.

Please join the TF Encrypted Slack. We will be answering questions in the tf-world-2019 channel!

Description

Today, we’re trying to take advantage of machine learning across many facets of modern life. However, many of our most impactful uses of machine learning in health care, transportation, and finance are blocked as they require access to sensitive data. In this tutorial, attendees will learn how to use TF Encrypted and PySyft to train and deploy machine learning models using remote execution, secure federated learning, and encrypted predictions in the cloud while preserving the privacy of both the model and the end user’s input data.

TF Encrypted and PySyft are complementary open-source libraries for designing and building privacy-preserving machine learning workflows. They both extend TensorFlow and aim to make privacy-preserving machine learning easy without needing to understand the complexities of cryptography, distributed systems, or high-performance computing.

Attendees will use TF Encrypted, PySyft and TensorFlow to train and deploy machine learning models to the cloud while preserving the privacy of both the model and the end user’s input data. After an introduction to the landscape of privacy-preserving machine learning, we'll dive into a series of hands-on exercises for building models with TF Encrypted’s secure primitives and PySyft-TensorFlow. Attendees will take away the skills needed to identify use cases requiring heightened privacy and security, as well as learn how to design, prototype, and deploy private machine learning.

Installation

To run these notebooks you will need to install:

To install all these dependencies you can simply run: pip3 install -r requirements.txt.

To manage dependencies, you can use a virtual environment like venv or a package manager like conda. Here's an example using conda:

conda create -n ppml python=3.7
conda activate ppml
pip install -r requirements.txt

The tutorial consists of three sequential parts:

  1. remote-execution
  2. federated-learning
  3. private-prediction

You can access and execute each step in the tutorial from the Jupyter console by running the command jupyter notebook from the root directory.

You can find the presentation slides here.

Google Cloud Installation

If you want to run this tutorial with Google Cloud Platform, you will need a GCP account and install Google SDK. See below for a quick reference to the installation procedure.

Run the following commands based on your OS to install gcloud tool.

MacOS

brew cask install google-cloud-sdk

Debian/Ubuntu

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates curl
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk

Initialize gcloud (Any OS)

Run the following command to initialize your Google Cloud configuration. You will have to complete the following:

  • Log into the account created above.
  • Set your default project to use, it will prompt you to create one if you haven't already made one.
  • Set your default zone and region to use.
gcloud init