Skip to content

Conversation

@dubovikmaster
Copy link

@dubovikmaster dubovikmaster commented Jan 28, 2023

  • Added the ability to use preprocessors of data such as keras.layers.Normalization or MinMaxScaler from sklearn.preprocessing for data preprocessing at each split into training and test samples during cross-validation. This allows the test to be closer to the actual use of the model.
  • Support for cases where the model has multiple inputs.
  • Added parameter eval_batch_size - allows you to control the size of the batch when validating the model on a test fold.
  • Fixed typos in README.md.
  • Added a description of new parameters to the README.md
  • Added import of the inner_cv function and the OuterCV class to the __init__.py, which now allows you to do from keras_tuner_cv import inner_cv or OuterCV instead of from keras_tuner_cv.inner_cv import inner_cv
  • The recently released version of keras-tuner 1.2 has incompatible changes. Therefore, I decided to limit the tuner version to version 1.1.3 with which keras-tuner-cv works.
  • Added scikit-learn to the install requires

@dubovikmaster
Copy link
Author

Hi @giuseppegrieco !
I hope you all are well!
In this pull request, I made a lot of fixes and improvements. Can you watch and accept it? Thank you very much for your work!

@Feheragyar
Copy link
Contributor

else:
                    metrics = tuner_utils.convert_to_metrics_dict(
                        results, self.oracle.objective, "Tuner.run_trial()"
                    )
                    metrics.update(get_metrics_std_dict(results))
                    self.oracle.update_trial(
                        trial.trial_id,
                        metrics,
                    )

Small bug fix for inner_cv.py module:
The "Tuner.run_trial()" arg needs to be deleted for the metric conversion to work correctly, as it can only take 2 args.

@Furkan-rgb
Copy link

Furkan-rgb commented Sep 21, 2023

Hey guys, first of all thanks for the efforts. I'm running into a problem related to this and I hope someone can help me out as I'm still fairly new to keras_tuner. When trying to run inner_cv, After the first trial I get this error:

    metrics = tuner_utils.convert_to_metrics_dict(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: convert_to_metrics_dict() takes 2 positional arguments but 3 were given

I have followed the examples but am unsure on what to do.
This is how I use it:

tuner = inner_cv(BayesianOptimization)(
    search_cnn_lstm_model,
    TimeSeriesSplit(n_splits=5),
    objective="val_loss",
    save_output=True,
    save_history=True,
    max_trials=max_trials,
    seed=42,
    executions_per_trial=2,
    directory="tmp/tb",
    project_name="cnn_lstm_vl_innercv",
)

tuner.search(
    X_train,
    y_train,
    epochs=120,
    shuffle=False,
    validation_data=(X_test, y_test),
    batch_size=72,
    callbacks=[
        tf.keras.callbacks.EarlyStopping(
            monitor="val_binary_accuracy", patience=10, mode="max"
        ),
    ],
    verbose=True,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants