with tfe.protocol.SecureNN():
tfe_model = tfe.keras.models.model_from_config(k_config)
x = tfe.define_private_variable(input_data)
with tfe.Session() as sess:
sess.run(tf.global_variables_initializer())
tfe_model.set_weights(k_weights)
y = tfe_model(x)
actual = sess.run(y.reveal())
np.testing.assert_allclose(actual, expected, rtol=1e-2, atol=1e-4)
After Change
input_shape)
with tfe.protocol.SecureNN():
x = tfe.define_private_input(
"inputter",
lambda: tf.convert_to_tensor(input_data))
tfe_model = tfe.keras.models.model_from_config(k_config)
tfe_model.set_weights(k_weights)
y = tfe_model(x)
with KE.get_session() as sess:
actual = sess.run(y.reveal())
np.testing.assert_allclose(actual, expected, rtol=1e-2, atol=1e-4)
KE.clear_session()
def test_from_config(self):
input_shape = (1, 3)
input_data = np.random.normal(size=input_shape)
expected, k_weights, k_config = _model_predict_keras(input_data,