Skip to content

Commit 592257d

Browse files
0.10.28
Fixes an error in get_tuned_architecture. If spot uses noise, then min_mean_X is returned.
1 parent 701d812 commit 592257d

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

notebooks/00_spotPython_tests.ipynb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,14 @@
23982398
" 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1]])\n",
23992399
"targets: tensor([2, 5, 7, 6, 1, 3])\n"
24002400
]
2401+
},
2402+
{
2403+
"ename": "",
2404+
"evalue": "",
2405+
"output_type": "error",
2406+
"traceback": [
2407+
"\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
2408+
]
24012409
}
24022410
],
24032411
"source": [

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.10.27"
10+
version = "0.10.28"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/hyperparameters/values.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,21 +936,29 @@ def get_default_hyperparameters_for_core_model(fun_control) -> dict:
936936
return values
937937

938938

939-
def get_tuned_architecture(spot_tuner, fun_control) -> dict:
939+
def get_tuned_architecture(spot_tuner, fun_control, force_minX=False) -> dict:
940940
"""
941-
Returns the tuned architecture.
941+
Returns the tuned architecture. If the spot tuner has noise,
942+
it returns the architecture with the lowest mean (.min_mean_X),
943+
otherwise it returns the architecture with the lowest value (.min_X).
942944
943945
Args:
944946
spot_tuner (object):
945947
spot tuner object.
946948
fun_control (dict):
947949
dictionary containing control parameters for the hyperparameter tuning.
950+
force_minX (bool):
951+
If True, return the architecture with the lowest value (.min_X).
948952
949953
Returns:
950954
(dict):
951955
dictionary containing the tuned architecture.
952956
"""
953-
X = spot_tuner.to_all_dim(spot_tuner.min_X.reshape(1, -1))
957+
if not spot_tuner.noise or force_minX:
958+
X = spot_tuner.to_all_dim(spot_tuner.min_X.reshape(1, -1))
959+
else:
960+
# noise or force_minX is False:
961+
X = spot_tuner.to_all_dim(spot_tuner.min_mean_X.reshape(1, -1))
954962
config = get_one_config_from_X(X, fun_control)
955963
return config
956964

0 commit comments

Comments
 (0)