From 6f6dea8b42eb24205c07a4776e71e0b07d2e0717 Mon Sep 17 00:00:00 2001 From: james-choncholas Date: Mon, 20 Jan 2025 19:33:46 +0000 Subject: [PATCH] Model tests use smaller learning rate to catch performance regression. --- tf_shell_ml/test/dpsgd_conv_model_local_test.py | 3 --- tf_shell_ml/test/dpsgd_model_distrib_test.py | 4 ++-- tf_shell_ml/test/dpsgd_model_float64_test.py | 2 +- tf_shell_ml/test/dpsgd_model_local_test.py | 2 +- tf_shell_ml/test/postscale_model_distrib_test.py | 2 +- tf_shell_ml/test/postscale_model_float64_test.py | 2 +- tf_shell_ml/test/postscale_model_local_test.py | 2 +- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tf_shell_ml/test/dpsgd_conv_model_local_test.py b/tf_shell_ml/test/dpsgd_conv_model_local_test.py index e3c8c16..64644fa 100644 --- a/tf_shell_ml/test/dpsgd_conv_model_local_test.py +++ b/tf_shell_ml/test/dpsgd_conv_model_local_test.py @@ -112,9 +112,6 @@ def _test_model(self, disable_encryption, disable_masking, disable_noise, cache) metrics=[tf.keras.metrics.CategoricalAccuracy()], ) - m.build([None, 28 - (2 * clip_by), 28 - (2 * clip_by), 1]) - m.summary() - history = m.fit( features_dataset, labels_dataset, diff --git a/tf_shell_ml/test/dpsgd_model_distrib_test.py b/tf_shell_ml/test/dpsgd_model_distrib_test.py index c567d2c..a21f909 100644 --- a/tf_shell_ml/test/dpsgd_model_distrib_test.py +++ b/tf_shell_ml/test/dpsgd_model_distrib_test.py @@ -108,7 +108,7 @@ def test_model(self): lambda read_from_cache: tf_shell.create_autocontext64( log2_cleartext_sz=25, scaling_factor=1, - noise_offset_log2=2, + noise_offset_log2=0, read_from_cache=read_from_cache, cache_path=cache, ), @@ -119,7 +119,7 @@ def test_model(self): m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], ) diff --git a/tf_shell_ml/test/dpsgd_model_float64_test.py b/tf_shell_ml/test/dpsgd_model_float64_test.py index c9ed1a7..4f3c190 100644 --- a/tf_shell_ml/test/dpsgd_model_float64_test.py +++ b/tf_shell_ml/test/dpsgd_model_float64_test.py @@ -79,7 +79,7 @@ def _test_model(self, disable_encryption, disable_masking, disable_noise, cache) m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], ) diff --git a/tf_shell_ml/test/dpsgd_model_local_test.py b/tf_shell_ml/test/dpsgd_model_local_test.py index 932cec0..27ceda0 100644 --- a/tf_shell_ml/test/dpsgd_model_local_test.py +++ b/tf_shell_ml/test/dpsgd_model_local_test.py @@ -79,7 +79,7 @@ def _test_model(self, disable_encryption, disable_masking, disable_noise, cache) m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], ) diff --git a/tf_shell_ml/test/postscale_model_distrib_test.py b/tf_shell_ml/test/postscale_model_distrib_test.py index 3c34dd3..c72ca03 100644 --- a/tf_shell_ml/test/postscale_model_distrib_test.py +++ b/tf_shell_ml/test/postscale_model_distrib_test.py @@ -115,7 +115,7 @@ def test_model(self): m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], ) diff --git a/tf_shell_ml/test/postscale_model_float64_test.py b/tf_shell_ml/test/postscale_model_float64_test.py index abd9a8c..697e92f 100644 --- a/tf_shell_ml/test/postscale_model_float64_test.py +++ b/tf_shell_ml/test/postscale_model_float64_test.py @@ -71,7 +71,7 @@ def _test_model(self, disable_encryption, disable_masking, disable_noise, cache) m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], ) diff --git a/tf_shell_ml/test/postscale_model_local_test.py b/tf_shell_ml/test/postscale_model_local_test.py index 00e2e49..6d44b10 100644 --- a/tf_shell_ml/test/postscale_model_local_test.py +++ b/tf_shell_ml/test/postscale_model_local_test.py @@ -71,7 +71,7 @@ def _test_model(self, disable_encryption, disable_masking, disable_noise, cache) m.compile( loss=tf.keras.losses.CategoricalCrossentropy(), - optimizer=tf.keras.optimizers.Adam(0.1), + optimizer=tf.keras.optimizers.Adam(0.01, beta_1=0.8), metrics=[tf.keras.metrics.CategoricalAccuracy()], )