8184b9fdf51e3f75835fe1f2d56c294d16686241,examples/federated_learning_with_encryption.py,,,#,162
Before Change
clients.append(Client("Carol", server.pubkey))
// Each client trains a linear regressor on its own data
for (i, c) in enumerate(clients):
c = c.fit(X[i], y[i], n_iter=50, eta=0.05)
print(c.weights)
// Predict
for (i, c) in enumerate(clients):
print("Train", mean_square_error(c.predict(X[i]), y[i]))
print("Test", mean_square_error(c.predict(X_test), y_test))
After Change
// Instantiate Alice, Bob and Carol.
// Each client gets the public key at creation
clients = []
for i in range(n_clients):
clients.append(Client(names[i], X[i], y[i], server.pubkey))
// Each client trains a linear regressor on its own data
// for (i, c) in enumerate(clients):
// c = c.fit(n_iter=50, eta=0.05)
// print(c.weights)
//
// // Predict
// for (i, c) in enumerate(clients):
// print("Train", mean_square_error(c.predict(X[i]), y[i]))
// print("Test", mean_square_error(c.predict(X_test), y_test))
// Each client sends its own model to the next one, in a RING protocol,
// aggregating them all. The last client sends the aggregate model to the server
// All those exchanges happen the encrypted domain, so neither any client
// sees in the clear the model of anybody else, nor the server reads any
// client"s individual model.
// encrypted_aggr = clients[0].encrypt_and_aggregate(input_model=None)
// encrypted_aggr = clients[1].encrypt_and_aggregate(input_model=encrypted_aggr)
// encrypted_aggr = clients[2].encrypt_and_aggregate(input_model=encrypted_aggr)
// aggr = server.decrypt_aggregate(encrypted_aggr, n_clients)
// print(aggr)
// for (i, c) in enumerate(clients):
// c.weights = aggr
// y_pred = c.predict(X_test)
// print(mean_square_error(y_pred, y_test))
// The federated learning with gradient from the google paper
n_iter = 5
for i in range(n_iter):
// Compute gradients, encrypt and aggregate
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 9
Instances
Project Name: data61/python-paillier
Commit Name: 8184b9fdf51e3f75835fe1f2d56c294d16686241
Time: 2017-06-20
Author: giorgio.patrini@anu.edu.au
File Name: examples/federated_learning_with_encryption.py
Class Name:
Method Name:
Project Name: pliablepixels/zmeventnotification
Commit Name: 1e619d91956c813d2328a5460da0a273fe135905
Time: 2019-11-15
Author: pliablepixels@gmail.com
File Name: hook/zmes_hook_helpers/face.py
Class Name: Face
Method Name: detect
Project Name: ilastik/ilastik
Commit Name: 558f030de16f0e3ea4ce860aac0d085faad99441
Time: 2019-08-13
Author: k-dominik@users.noreply.github.com
File Name: ilastik/applets/batchProcessing/batchProcessingGui.py
Class Name: BatchProcessingGui
Method Name: run_export