DISCLAIMER: This is a proof-of-concept implementation. It does not represent a remotely product ready implementation or follow proper conventions for security, convenience, or scalability. It is part of a broader proof-of-concept demonstrating the vision of the OpenMined project, its major moving parts, and how they might work together.
In [11]:
from syft.he.paillier import KeyPair
from syft.nn.linear import LinearClassifier
import numpy as np
In [12]:
pubkey,prikey = KeyPair().generate(n_length=1024)
In [13]:
model = LinearClassifier(n_inputs=4,n_labels=2).encrypt(pubkey)
In [14]:
input = np.array([[0,0,1,1],[0,0,1,0],[1,0,1,1],[0,0,1,0]])
target = np.array([[0,1],[0,0],[1,1],[0,0]])
In [15]:
for iter in range(3):
for i in range(len(input)):
print("Grads:" + str((model.learn(input=input[i],target=target[i],alpha=0.5))))
In [16]:
model = model.decrypt(prikey)
In [17]:
for i in range(len(input)):
print(model.forward(input[i]))
In [ ]:
In [ ]: