From f5acef300a7a3b1967dc47a98f3aaebbd5678fdd Mon Sep 17 00:00:00 2001 From: Franck Mamalet <49721198+franckma31@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:28:50 +0100 Subject: [PATCH] remove reference to Keras in test files --- deel/torchlip/modules/module.py | 2 +- tests/test_compute_layer_sv.py | 4 ++-- tests/test_condense.py | 2 +- tests/test_initializers.py | 2 +- tests/test_layers.py | 4 ++-- tests/test_models.py | 8 +++----- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/deel/torchlip/modules/module.py b/deel/torchlip/modules/module.py index fb651b4..ccc8f62 100644 --- a/deel/torchlip/modules/module.py +++ b/deel/torchlip/modules/module.py @@ -44,7 +44,7 @@ def _is_supported_1lip_layer(layer): - """Return True if the Keras layer is 1-Lipschitz. Note that in some cases, the layer + """Return True if the layer is 1-Lipschitz. Note that in some cases, the layer is 1-Lipschitz for specific set of parameters. """ supported_1lip_layers = ( diff --git a/tests/test_compute_layer_sv.py b/tests/test_compute_layer_sv.py index 61ad415..9d37fca 100644 --- a/tests/test_compute_layer_sv.py +++ b/tests/test_compute_layer_sv.py @@ -142,7 +142,7 @@ def train_compute_and_verifySV( input_shape = uft.to_framework_channel(input_shape) # tf.random.uft.set_seed(1234) - # create the keras model, defin opt, and compile it + # create the model, defin opt, and compile it model = uft.generate_k_lip_model(layer_type, layer_params, input_shape, k_lip_model) optimizer = uft.get_instance_framework( @@ -166,7 +166,7 @@ def train_compute_and_verifySV( logdir = os.path.join("logs", uft.LIP_LAYERS, "%s" % layer_type.__name__) os.makedirs(logdir, exist_ok=True) - callback_list = [] # [hp.KerasCallback(logdir, hparams)] + callback_list = [] if "callbacks" in kwargs and (kwargs["callbacks"] is not None): callback_list = callback_list + kwargs["callbacks"] # train model diff --git a/tests/test_condense.py b/tests/test_condense.py index 0c6cb7c..8930640 100644 --- a/tests/test_condense.py +++ b/tests/test_condense.py @@ -202,7 +202,7 @@ def test_model(layer_type, layer_params, k_coef_lip, input_shape): model = get_model(layer_type, layer_params, input_shape, k_coef_lip) - # create the keras model, defin opt, and compile it + # create the model, defin opt, and compile it optimizer = uft.get_instance_framework( uft.Adam, inst_params={"lr": 0.001, "model": model} ) diff --git a/tests/test_initializers.py b/tests/test_initializers.py index 2ef3afe..f4ee2c6 100644 --- a/tests/test_initializers.py +++ b/tests/test_initializers.py @@ -71,7 +71,7 @@ def test_initializer(layer_type, layer_params, input_shape, orthogonal_test): # clear session to avoid side effects from previous train uft.init_session() # K.clear_session() input_shape = uft.to_framework_channel(input_shape) - # create the keras model, defin opt, and compile it + # create the model, defin opt, and compile it model = uft.generate_k_lip_model(layer_type, layer_params, input_shape) uft.initialize_kernel(model, 0, layer_params["kernel_initializer"]) diff --git a/tests/test_layers.py b/tests/test_layers.py index 5126700..107d0d8 100644 --- a/tests/test_layers.py +++ b/tests/test_layers.py @@ -172,7 +172,7 @@ def train_k_lip_model( uft.init_session() # K.clear_session() np.random.seed(42) input_shape = uft.to_framework_channel(input_shape) - # create the keras model, defin opt, and compile it + # create the model, defin opt, and compile it model = uft.generate_k_lip_model(layer_type, layer_params, input_shape, k_lip_model) optimizer = uft.get_instance_framework( @@ -195,7 +195,7 @@ def train_k_lip_model( callback_list = ( [] - ) # [callbacks.TensorBoard(logdir), hp.KerasCallback(logdir, hparams)] + ) if kwargs["callbacks"] is not None: callback_list = callback_list + kwargs["callbacks"] # train model diff --git a/tests/test_models.py b/tests/test_models.py index 560b4d5..d68eacc 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -155,8 +155,8 @@ def assert_model_outputs(input_shape, model1, model2): np.testing.assert_allclose(uft.to_numpy(y2), uft.to_numpy(y1), atol=1e-5) -def test_keras_Sequential(): - """Assert vanilla conversion of a tf.keras.Sequential model""" +def test_Sequential(): + """Assert vanilla conversion of a Sequential model""" input_shape = uft.to_framework_channel((3, 20, 20)) model = uft.generate_k_lip_model( tSequential, @@ -203,14 +203,12 @@ def test_deel_lip_Sequential(): reason="tModel not available", ) def test_Model(): - """Assert vanilla conversion of a tf.keras.Model model""" + """Assert vanilla conversion of a Model model""" input_shape = uft.to_framework_channel((3, 8, 8)) dict_tensors = get_functional_tensors(input_shape) model = uft.get_functional_model( tModel, dict_tensors, functional_input_output_tensors ) - # inputs, outputs = functional_input_output_tensors() - # model = tf.keras.Model(inputs, outputs) if uft.vanilla_require_a_copy(): dict_tensors2 = get_functional_tensors(input_shape) model2 = uft.get_functional_model(