From 87745f0d724df730512fbaf30cd914a4d473e328 Mon Sep 17 00:00:00 2001 From: Mikko Kotila Date: Sun, 21 Apr 2024 11:36:54 +0300 Subject: [PATCH] generalize loss init --- talos/templates/params.py | 6 ++---- tests/commands/test_templates.py | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/talos/templates/params.py b/talos/templates/params.py index a6b154d2..8d736838 100644 --- a/talos/templates/params.py +++ b/talos/templates/params.py @@ -35,7 +35,6 @@ def titanic(debug=False): def iris(): from tensorflow.keras.optimizers.legacy import Adam, Adagrad - from tensorflow.keras.losses import LogCosh, categorical_crossentropy from tensorflow.keras.activations import relu, elu, softmax # here use a standard 2d dictionary for inputting the param boundaries @@ -49,7 +48,7 @@ def iris(): 'emb_output_dims': [None], 'shapes': ['brick', 'triangle', 0.2], 'optimizer': [Adam, Adagrad], - 'losses': [LogCosh, categorical_crossentropy], + 'losses': ['LogCosh', 'categorical_crossentropy'], 'activation': [relu, elu], 'last_activation': [softmax]} @@ -59,7 +58,6 @@ def iris(): def breast_cancer(): from tensorflow.keras.optimizers.legacy import Adam, Adagrad, RMSprop - from tensorflow.keras.losses import LogCosh, binary_crossentropy from tensorflow.keras.activations import relu, elu, sigmoid # then we can go ahead and set the parameter space @@ -71,7 +69,7 @@ def breast_cancer(): 'dropout': (0, 0.5, 5), 'shapes': ['brick', 'triangle', 'funnel'], 'optimizer': [Adam, Adagrad, RMSprop], - 'losses': [LogCosh, binary_crossentropy], + 'losses': ['LogCosh', 'binary_crossentropy'], 'activation': [relu, elu], 'last_activation': [sigmoid]} diff --git a/tests/commands/test_templates.py b/tests/commands/test_templates.py index af647086..f1339f78 100644 --- a/tests/commands/test_templates.py +++ b/tests/commands/test_templates.py @@ -12,6 +12,7 @@ def test_templates(): talos.Scan(x, y, p, model, 'test_', round_limit=2) x, y = talos.templates.datasets.iris() + x = x[:50] y = y[:50] model = talos.templates.models.iris