From f45ec47b1b848862dfa30cca16d5d44ae5617147 Mon Sep 17 00:00:00 2001 From: openGaussDev Date: Tue, 8 Mar 2022 12:31:49 +0800 Subject: [PATCH] Narrowing the range of iteration times Offering: openGaussDev More detail: Narrowing the range of iteration times Match-id-e8830353af1a99500aa8e97a0a0894b2872e4f24 --- src/gausskernel/dbmind/db4ai/executor/gd/pca.cpp | 2 +- src/gausskernel/dbmind/db4ai/executor/kmeans/kmeans.cpp | 2 +- src/gausskernel/dbmind/db4ai/executor/xgboost/xgboost.cpp | 2 +- src/include/db4ai/db4ai_common.h | 1 + src/include/db4ai/gd.h | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gausskernel/dbmind/db4ai/executor/gd/pca.cpp b/src/gausskernel/dbmind/db4ai/executor/gd/pca.cpp index f4241344a..3cad823ea 100644 --- a/src/gausskernel/dbmind/db4ai/executor/gd/pca.cpp +++ b/src/gausskernel/dbmind/db4ai/executor/gd/pca.cpp @@ -258,7 +258,7 @@ static HyperparameterDefinition pca_hyperparameter_definitions[] = { HYPERPARAMETER_INT4("number_components", 1, 1, true, INT32_MAX, true, HyperparametersGD, number_dimensions, HP_NO_AUTOML()), HYPERPARAMETER_INT4("batch_size", 1000, 1, true, INT32_MAX, true, HyperparametersGD, batch_size, HP_NO_AUTOML()), - HYPERPARAMETER_INT4("max_iterations", 100, 1, true, INT32_MAX, true, HyperparametersGD, max_iterations, + HYPERPARAMETER_INT4("max_iterations", 100, 1, true, ITER_MAX, true, HyperparametersGD, max_iterations, HP_NO_AUTOML()), HYPERPARAMETER_INT4("max_seconds", 0, 0, true, INT32_MAX, true, HyperparametersGD, max_seconds, HP_NO_AUTOML()), HYPERPARAMETER_FLOAT8("tolerance", 0.0005, 0.0, true, DBL_MAX, true, HyperparametersGD, tolerance, HP_NO_AUTOML()), diff --git a/src/gausskernel/dbmind/db4ai/executor/kmeans/kmeans.cpp b/src/gausskernel/dbmind/db4ai/executor/kmeans/kmeans.cpp index 170b73c0e..7ded06b65 100644 --- a/src/gausskernel/dbmind/db4ai/executor/kmeans/kmeans.cpp +++ b/src/gausskernel/dbmind/db4ai/executor/kmeans/kmeans.cpp @@ -1041,7 +1041,7 @@ HyperparameterDefinition kmeans_hyperparameter_definitions[] = { HYPERPARAMETER_INT4("verbose", 0, 0, true, 2, true, HyperparametersKMeans, verbosity, HP_NO_AUTOML()), HYPERPARAMETER_INT4("num_centroids", 1, 1, true, 1000000, true, HyperparametersKMeans, num_centroids, HP_NO_AUTOML()), - HYPERPARAMETER_INT4("max_iterations", 10, 1, true, INT32_MAX, true, HyperparametersKMeans, num_iterations, + HYPERPARAMETER_INT4("max_iterations", 10, 1, true, ITER_MAX, true, HyperparametersKMeans, num_iterations, HP_NO_AUTOML()), HYPERPARAMETER_INT4("num_features", 0, 1, true, INT32_MAX, true, HyperparametersKMeans, n_features, HP_NO_AUTOML()), HYPERPARAMETER_INT4("batch_size", 1000, 1, true, 1000000, true, HyperparametersKMeans, batch_size, HP_NO_AUTOML()), diff --git a/src/gausskernel/dbmind/db4ai/executor/xgboost/xgboost.cpp b/src/gausskernel/dbmind/db4ai/executor/xgboost/xgboost.cpp index 7f044417a..288caf004 100644 --- a/src/gausskernel/dbmind/db4ai/executor/xgboost/xgboost.cpp +++ b/src/gausskernel/dbmind/db4ai/executor/xgboost/xgboost.cpp @@ -225,7 +225,7 @@ const char *xgboost_boost_str[] = {"gbtree", "gblinear", "dart"}; const char *xgboost_tree_method_str[] = {"auto", "exact", "approx", "hist", "gpu_hist"}; const char *xgboost_eval_metric_str[] = {"rmse", "rmsle", "map", "mae", "auc", "aucpr" }; static HyperparameterDefinition xgboost_hyperparameter_definitions[] = { - HYPERPARAMETER_INT4("n_iter", 10, 1, true, INT32_MAX, true, HyperparamsXGBoost, n_iterations, HP_NO_AUTOML()), + HYPERPARAMETER_INT4("n_iter", 10, 1, true, ITER_MAX, true, HyperparamsXGBoost, n_iterations, HP_NO_AUTOML()), HYPERPARAMETER_INT4("batch_size", 10000, 1, true, INT32_MAX, true, HyperparamsXGBoost, batch_size, HP_NO_AUTOML()), HYPERPARAMETER_INT4("max_depth", 5, 0, true, INT32_MAX, true, HyperparamsXGBoost, max_depth, HP_NO_AUTOML()), HYPERPARAMETER_INT4("min_child_weight", 1, 0, true, INT32_MAX, true, HyperparamsXGBoost, min_child_weight, diff --git a/src/include/db4ai/db4ai_common.h b/src/include/db4ai/db4ai_common.h index aad1a8eaa..104ea26c7 100644 --- a/src/include/db4ai/db4ai_common.h +++ b/src/include/db4ai/db4ai_common.h @@ -25,6 +25,7 @@ #include "utils/builtins.h" #include "utils/timestamp.h" +#define ITER_MAX 10000 uint64_t time_diff(struct timespec *time_p1, struct timespec *time_p2); double interval_to_sec(double time_interval); diff --git a/src/include/db4ai/gd.h b/src/include/db4ai/gd.h index 0e80274fe..471a6b6ab 100644 --- a/src/include/db4ai/gd.h +++ b/src/include/db4ai/gd.h @@ -270,7 +270,7 @@ typedef struct HyperparametersGD { HYPERPARAMETER_FLOAT8("learning_rate", 0.8, 0.0, false, DBL_MAX, true, \ HyperparametersGD, learning_rate, \ HP_AUTOML_FLOAT(1E-6, 1E3, 9, ProbabilityDistribution::LOG_RANGE)), \ - HYPERPARAMETER_INT4("max_iterations", 100, 1, true, INT32_MAX, true, \ + HYPERPARAMETER_INT4("max_iterations", 100, 1, true, ITER_MAX, true, \ HyperparametersGD, max_iterations, \ HP_AUTOML_INT(1, 100, 10, ProbabilityDistribution::LOG_RANGE)), \ HYPERPARAMETER_INT4("max_seconds", 0, 0, true, INT32_MAX, true, \