在上一教程中,我们一直在手工初始化hook和所有工作机。 当您只是在玩耍/了解接口时,这可能会有些烦人。因此,从现在开始,我们将使用特殊的便捷函数创建所有这些相同的变量。 In the last tutorials, we've been initializing our hook and all of our workers by hand every time. This can be a bit annoying when you're just playing around / learning about the interfaces. So, from here on out we'll be creating all these same variables using a special convenience function.
In [ ]:
import torch
import syft as sy
sy.create_sandbox(globals())
In [ ]:
workers
我们还填充了大量的全局变量,我们可以立即使用的!
In [ ]:
hook
In [ ]:
bob
In [ ]:
torch.Tensor([1,2,3,4,5])
In [ ]:
x = torch.tensor([1,2,3,4,5]).tag("#fun", "#boston", "#housing").describe("The input datapoints to the boston housing dataset.")
y = torch.tensor([1,2,3,4,5]).tag("#fun", "#boston", "#housing").describe("The input datapoints to the boston housing dataset.")
z = torch.tensor([1,2,3,4,5]).tag("#fun", "#mnist",).describe("The images in the MNIST training dataset.")
In [ ]:
x
In [ ]:
x = x.send(bob)
y = y.send(bob)
z = z.send(bob)
# 这会在标签或说明中搜索完全匹配
results = bob.search(["#boston", "#housing"])
In [ ]:
results
In [ ]:
print(results[0].description)
In [ ]:
grid = sy.PrivateGridNetwork(*workers)
In [ ]:
results= grid.search("#boston")
In [ ]:
boston_data = grid.search("#boston","#data")
In [ ]:
boston_target = grid.search("#boston","#target")
In [ ]: