import tensorflow as tf
import tf_encrypted as tfe
@tfe.local_computation('input-provider')
def provide_input():
# normal TensorFlow operations can be run locally
# as part of defining a private input, in this
# case on the machine of the input provider
return tf.ones(shape=(5, 10))
# provide inputs
w = tfe.define_private_variable(tf.ones(shape=(10,10)))
x = provide_input()
# eager execution
y = tfe.matmul(x, w)
res = y.reveal().to_native()
# build graph and run graph
@tfe.function
def matmul_func(x, w):
y = tfe.matmul(x, w)
return y.reveal().to_native()
res = matmul_func(x, w)
print(res)
tf-encrypted相关样例
最新推荐文章于 2025-05-27 20:07:06 发布