Skip to content

Instantly share code, notes, and snippets.

View jvmncs's full-sized avatar
📖

jvmncs

📖
View GitHub Profile
alice = syft.VirtualWorker(hook, “alice”)
x = tf.constant([1., 2., 3., 4.])
x_ptr = x.send(alice)
print(x_ptr)
# ==> (Wrapper)>[PointerTensor | me:random_id1 -> alice:random_id2]
import tensorflow as tf
import syft
hook = syft.TensorFlowHook(tf)
def matmul(prot: Pond,
x: PondMaskedTensor,
y: PondMaskedTensor):
a, a0, a1, alpha_on_0, alpha_on_1 = x.unwrapped
b, b0, b1, beta_on_0, beta_on_1 = y.unwrapped
with tf.device(prot.crypto_producer.device_name):
ab = a.matmul(b)
ab0, ab1 = prot._share(ab)
@jvmncs
jvmncs / neurips_tf_minimal.py
Last active November 30, 2018 22:59
TensorFlow equivalent of neurips_tfe_minimal.py
import tensorflow as tf
# generic function stubs
def provide_weights(): """Load model weights."""
def provide_input(): """Load input data."""
# get model weights/input data
# (both unencrypted)
@jvmncs
jvmncs / neurips_tfe_minimal.py
Last active November 30, 2018 22:41
A minimal example of using tf-encrypted for secure inference, shortened for our NeurIPS poster
import tensorflow as tf
import tf_encrypted as tfe
# generic remote procedure calls
def provide_weights(): """Load model weights."""
def provide_input(): """Load input data."""
def receive_output(): """Receive and decrypt output."""
# get model weights/input data
# as private tensors from each party
@jvmncs
jvmncs / tf_minimal.py
Last active November 28, 2018 23:18
TensorFlow equivalent of tfe_minimal.py
import tensorflow as tf
# generic functions for loading model weights and input data
def provide_weights(): """Load model weights as TensorFlow objects."""
def provide_input(): """Load input data as TensorFlow objects."""
# get model weights/input data (both unencrypted)
w0, b0, w1, b1, w2, b2 = provide_weights()
x = provide_input()
@jvmncs
jvmncs / tfe_minimal.py
Last active October 18, 2018 18:29
A minimal example of using tf-encrypted for secure inference
import tensorflow as tf
import tf_encrypted as tfe
# define the parties
tfe.set_config(tfe.RemoteConfig({
"model-owner": "localhost:2222",
"prediction-client": "1.2.3.4:2222",
"server0": "1.1.1.1:4444",
"server1": "1.1.1.2:4444"})

Keybase proof

I hereby claim:

  • I am jvmncs on github.
  • I am jvmancuso (https://keybase.io/jvmancuso) on keybase.
  • I have a public key ASBM8wtPG4iKMnoJtJe5BUMW5LzNCnji9L3gh-WJzBnKrgo

To claim this, I am signing this object: