Federated Learning (Data Owner)
Published by by Leo Wei
Before reading the rest of this blog, make sure you have the Federated Learning (Data Scientist) open side by side.
As a data owner, you want someone else to perform data science on data that you own, and you also want to protect this data by not give them the entirety of your data.
To do this, we can load our data into our local duet
server.
To begin the process, you must launch a Duet session and help your Duet partner (data scientist) connect to this server.
Make sure that the network_url you use is chosen from https://raw.githubusercontent.com/OpenMined/OpenGridNodes/master/network_address
import syft as sy
duet = sy.launch_duet(network_url="http://ec2-18-218-7-180.us-east-2.compute.amazonaws.com:5000")
Step 2. Go to Data Scientist Notebook
After we have established connection between the data owner and the data scientist. Let's upload some data to the Duet server
import torch as th
grade_data = th.tensor([98, 78, 83, 88, 67, 73])
grade_data = grade_data.tag("grades")
grade_data = grade_data.describe("This is a list of the grades of 6 people")
# server, note that the data is still on the owner's machine and cannot be viewed or access
# without the permission from the data owner
grade_data_pointer = grade_data.send(duet, pointable = True)
Step 4. Go to Data Scientist Notebook
duet.requests.pandas
duet.requests[0].deny()
Step 6. Go to Data Scientist Notebook
duet.requests.pandas
duet.requests[0].request_description
duet.requests[0].accept()
Step 8. Go to Data Scientist Notebook
from syft.util import get_root_data_path
import torchvision
torchvision.datasets.MNIST(get_root_data_path(), train=True,
download=True,
transform = torchvision.transforms.Compose([torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.1307,), (0.3081,))]))
torchvision.datasets.MNIST(get_root_data_path(), train=False,
download=True,
transform = torchvision.transforms.Compose([torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.1307,), (0.3081,))]))
duet.requests.pandas
duet.store.pandas
# duet.requests.add_handler(action = "deny")
duet.requests.add_handler(action="accept")
We have done everything on the data owner's side, the rest is continued on the data scientist's notebook
Step 10. Go to Data Scientist Notebook