· 6 years ago · Aug 19, 2019, 04:46 PM
1def sigmoid(x):
2 # the following polynomial evaluation approximates by computing
3 # 0.5 + 0.197x + -0.004x³, the 0.0 term is ignored.
4 coeffs = np.array([0.5, 0.197, 0.0, -0.004])
5 return tf_seal.poly_eval(x, coeffs)
6
7public_keys, secret_key = tfs.seal_key_gen(gen_relin=True, gen_galois=True)
8
9# encrypted input -> tf_seal.Tensor
10a_plain = # … random tensor
11a = tf_seal.constant(a_plain, secret_key, public_keys)
12
13# public weights
14b = # … random tensor
15
16c = tfs.matmul(a, b)
17d = sigmoid(c)
18
19# run graph