Skip to content

Instantly share code, notes, and snippets.

View mortendahl's full-sized avatar

Morten Dahl mortendahl

View GitHub Profile
# compute and collect all model gradients as private inputs
model_grads = zip(*[
tfe.define_private_input(
data_owner.player_name,
data_owner.compute_gradient)
for data_owner in data_owners
])
# compute mean gradient securely
aggregated_model_grads = [
import tensorflow as tf
import tf_encrypted as tfe
class PredictionClient:
@tfe.private_input
def provide_input(self):
"""Load and preprocess input data."""
@tfe.private_output
x_train_0, y_train_0 = tfe.define_private_input(
data_owner_0.player_name,
data_owner_0.provide_training_data)
x_train_1, y_train_1 = tfe.define_private_input(
data_owner_1.player_name,
data_owner_1.provide_training_data)
x_train = tfe.concat([x_train_0, x_train_1], axis=0)
y_train = tfe.concat([y_train_0, y_train_1], axis=0)
import tensorflow as tf
def provide_weights():""" Load from disk """
def provide_input(): """ Pre-process """
def receive_output(logits): return tf.print(tf.argmax(logits))
# get model weights
w0, b0, w1, b1, w2, b2 = provide_weights()
# get prediction input
import tensorflow as tf
import tf_encrypted as tfe
def provide_weights(): """Load model weight from disk using TensorFlow."""
def provide_input(): """Load and preprocess input data locally on the client."""
def receive_output(logits): return tf.print(tf.argmax(logits))
w0, b0, w1, b1, w2, b2 = provide_weights()
# run provide_input locally on the client and encrypt

Keybase proof

I hereby claim:

  • I am mortendahl on github.
  • I am mortendahl (https://keybase.io/mortendahl) on keybase.
  • I have a public key ASAKQjQ6aPe_9DuRi8wdIfatfopYbMJVRcC2qsrjuXEQTgo

To claim this, I am signing this object: