From 23bde187aebfa5ba440fd144890a7699a4da18c8 Mon Sep 17 00:00:00 2001 From: Mikko Kotila Date: Sat, 20 Apr 2024 17:16:27 +0300 Subject: [PATCH] what feels like many small fixes --- .github/workflows/deploy-old.yml | 26 -------------------------- talos/autom8/autoparams.py | 2 +- talos/model/normalizers.py | 4 ++-- talos/templates/datasets.py | 4 ++-- talos/templates/models.py | 7 ++++--- talos/templates/params.py | 6 +++--- talos/templates/pipelines.py | 5 +++-- talos/utils/recover_best_model.py | 2 +- test-ci.py | 8 ++++---- tests/commands/test_analyze.py | 20 ++++++++++++++++++-- 10 files changed, 38 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/deploy-old.yml diff --git a/.github/workflows/deploy-old.yml b/.github/workflows/deploy-old.yml deleted file mode 100644 index 21f2f01d..00000000 --- a/.github/workflows/deploy-old.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Upload Python Package - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/talos/autom8/autoparams.py b/talos/autom8/autoparams.py index 6cb1e8b2..d8a9b8ce 100644 --- a/talos/autom8/autoparams.py +++ b/talos/autom8/autoparams.py @@ -1,5 +1,5 @@ import numpy as np -from tensorflow.keras.optimizers import Adam, Nadam, Adadelta, SGD +from tensorflow.keras.optimizers.legacy import Adam, Nadam, Adadelta, SGD loss = {'binary': ['binary_crossentropy', 'logcosh'], diff --git a/talos/model/normalizers.py b/talos/model/normalizers.py index 0071f9bd..586541ed 100644 --- a/talos/model/normalizers.py +++ b/talos/model/normalizers.py @@ -11,8 +11,8 @@ def lr_normalizer(lr, optimizer): The optimizer. For example, Adagrad, Adam, RMSprop. """ - from tensorflow.keras.optimizers import SGD, Adam, Adadelta, Adagrad, Adamax, RMSprop - from tensorflow.keras.optimizers import Nadam + from tensorflow.keras.optimizers.legacy import SGD, Adam, Adadelta, Adagrad, Adamax, RMSprop + from tensorflow.keras.optimizers.legacy import Nadam from talos.utils.exceptions import TalosModelError if optimizer == Adadelta: diff --git a/talos/templates/datasets.py b/talos/templates/datasets.py index 2460eb86..53ed6ff5 100755 --- a/talos/templates/datasets.py +++ b/talos/templates/datasets.py @@ -20,7 +20,7 @@ def telco_churn(quantile=.5): df = pd.read_csv('https://raw.githubusercontent.com/autonomio/examples/master/telco_churn/telco_churn_for_sensitivity.csv') - df = df.drop(['val_acc', 'loss', 'f1score', 'acc', 'round_epochs'], 1) + df = df.drop(['val_acc', 'loss', 'f1score', 'acc', 'round_epochs'], axis=1) for col in df.iloc[:, 2:].columns: df = wrangle.col_to_multilabel(df, col) @@ -34,7 +34,7 @@ def telco_churn(quantile=.5): y1 = df.C0.values y2 = df.C1.values - x = df.drop(['C0', 'C1'], 1).values + x = df.drop(['C0', 'C1'], axis=1).values return x, [y1, y2] diff --git a/talos/templates/models.py b/talos/templates/models.py index 796f822b..b3552993 100644 --- a/talos/templates/models.py +++ b/talos/templates/models.py @@ -103,12 +103,13 @@ def titanic(x_train, y_train, x_val, y_val, params): metrics=['acc']) # here we are also using the early_stopper function for a callback - out = model.fit(x=x_train, - y=y_train, + out = model.fit(x=x_train.astype('float32'), + y=y_train.astype('float32'), batch_size=params['batch_size'], epochs=params['epochs'], verbose=0, - validation_data=(x_val, y_val)) + validation_data=(x_val.astype('float32'), + y_val.astype('float32'))) return out, model diff --git a/talos/templates/params.py b/talos/templates/params.py index aab1d233..b627baf4 100644 --- a/talos/templates/params.py +++ b/talos/templates/params.py @@ -1,6 +1,6 @@ def titanic(debug=False): - from tensorflow.keras.optimizers import Adam, Nadam + from tensorflow.keras.optimizers.legacy import Adam, Nadam # here use a standard 2d dictionary for inputting the param boundaries p = {'lr': (0.5, 5, 10), @@ -34,7 +34,7 @@ def titanic(debug=False): def iris(): - from tensorflow.keras.optimizers import Adam, Nadam + from tensorflow.keras.optimizers.legacy import Adam, Nadam from tensorflow.keras.losses import logcosh, categorical_crossentropy from tensorflow.keras.activations import relu, elu, softmax @@ -58,7 +58,7 @@ def iris(): def breast_cancer(): - from tensorflow.keras.optimizers import Adam, Nadam, RMSprop + from tensorflow.keras.optimizers.legacy import Adam, Nadam, RMSprop from tensorflow.keras.losses import logcosh, binary_crossentropy from tensorflow.keras.activations import relu, elu, sigmoid diff --git a/talos/templates/pipelines.py b/talos/templates/pipelines.py index 81ba5f42..5ccf735c 100644 --- a/talos/templates/pipelines.py +++ b/talos/templates/pipelines.py @@ -44,8 +44,9 @@ def titanic(round_limit=2, random_method='uniform_mersenne', debug=False): '''Performs a Scan with Iris dataset and simple dense net''' import talos as ta - scan_object = ta.Scan(ta.templates.datasets.titanic()[0], - ta.templates.datasets.titanic()[1], + + scan_object = ta.Scan(ta.templates.datasets.titanic()[0].astype('float32'), + ta.templates.datasets.titanic()[1].astype('float32'), ta.templates.params.titanic(debug), ta.templates.models.titanic, 'test', diff --git a/talos/utils/recover_best_model.py b/talos/utils/recover_best_model.py index 8b2fc27f..4f50019a 100644 --- a/talos/utils/recover_best_model.py +++ b/talos/utils/recover_best_model.py @@ -53,7 +53,7 @@ def recover_best_model(x_train, # get the params for the model and train it params = df.sort_values(metric, ascending=False) - params = params.drop(metric, 1).iloc[i].to_dict() + params = params.drop(metric, axis=1).iloc[i].to_dict() _history, model = input_model(x_train, y_train, x_val, y_val, params) # start kfold cross-validation diff --git a/test-ci.py b/test-ci.py index b668586d..870f677b 100755 --- a/test-ci.py +++ b/test-ci.py @@ -4,17 +4,17 @@ from tests.commands import * + scan_object = test_scan() + ''' test_latest() - scan_object = test_scan() recover_best_model() test_random_methods() test_autom8() - test_templates() - - # test_analyze(scan_object) + test_templates()''' + test_analyze(scan_object) test_lr_normalizer() test_predict() diff --git a/tests/commands/test_analyze.py b/tests/commands/test_analyze.py index aac1fab9..d4a64564 100644 --- a/tests/commands/test_analyze.py +++ b/tests/commands/test_analyze.py @@ -20,14 +20,30 @@ def test_analyze(scan_object): # test the object properties r.best_params('val_loss', ['val_acc']) - r.correlate('val_loss', ['val_acc']) + r.correlate('val_loss', ['val_acc', + 'start', + 'end', + 'activation', + 'optimizer', + 'losses', + 'shapes']) r.data r.high('val_acc') r.low('val_acc') + + + + # r.plot_bars('first_neuron', 'val_acc', 'dropout', 'hidden_layers') r.plot_box('first_neuron', 'val_acc') - r.plot_corr('val_loss', ['val_acc']) + r.plot_corr('val_loss', ['val_acc', + 'start', + 'end', + 'activation', + 'optimizer', + 'losses', + 'shapes']) r.plot_hist('val_acc') r.plot_kde('val_acc') r.plot_line('val_acc')