Skip to content

Instantly share code, notes, and snippets.

@mortendahl
Last active May 17, 2019 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mortendahl/f873d27e6c371a3b791c390c7b3dde0b to your computer and use it in GitHub Desktop.
Save mortendahl/f873d27e6c371a3b791c390c7b3dde0b to your computer and use it in GitHub Desktop.
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
def receive_output(self, logits):
return tf.print(tf.argmax(logits))
model = tfe.models.Sequential([
tfe.keras.layers.Dense(activation='relu'),
tfe.keras.layers.Dense(activation='relu'),
tfe.keras.layers.Dense(activation=None)
])
prediction_client = PredictionClient()
x = prediction_client.provide_input()
y = model.predict(x)
prediction_client.receive_output(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment