Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_best_architecture fails with tf.keras.metrics objects #309

Open
maltelueken opened this issue Dec 20, 2022 · 0 comments
Open

find_best_architecture fails with tf.keras.metrics objects #309

maltelueken opened this issue Dec 20, 2022 · 0 comments

Comments

@maltelueken
Copy link
Member

When giving a tf.keras.metrics object as metric in find_best_architecture(), e.g., find_best_architecture(..., metric=tf.keras.metrics.Precision()), an error is raised:

models = modelgen.generate_models(X_train.shape, y_train.shape[1],
                                   number_of_models=number_of_models,
                                   task=task,
                                   metrics=[metric],
                                   **kwargs)
 _, val_performance, _ = train_models_on_samples(X_train,
                                                y_train,
                                                X_val,
   (...)
                                                model_path=model_path,
                                                class_weight=class_weight)
--> best_model_index = np.argmax(val_performance[metric])

ValueError: attempt to get argmax of an empty sequence

The error occurs because find_best_architecture() stores the metric scores on the validation set in the dictionary val_performance and uses the metric string as a key. When supplying a keras metrics object, an empty list is returned because the dictionary has no corresponding metric string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Sprint December 2022
Awaiting triage
Development

No branches or pull requests

1 participant