Skip to content

Commit 94f5f35

Browse files
0.23.0_alpha
1 parent d7a1015 commit 94f5f35

7 files changed

Lines changed: 648 additions & 238 deletions

File tree

notebooks/00_spotPython_tests.ipynb

Lines changed: 219 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -7192,37 +7192,9 @@
71927192
},
71937193
{
71947194
"cell_type": "code",
7195-
"execution_count": 1,
7195+
"execution_count": null,
71967196
"metadata": {},
7197-
"outputs": [
7198-
{
7199-
"name": "stderr",
7200-
"output_type": "stream",
7201-
"text": [
7202-
"Seed set to 123\n",
7203-
"Seed set to 123\n"
7204-
]
7205-
},
7206-
{
7207-
"name": "stdout",
7208-
"output_type": "stream",
7209-
"text": [
7210-
"S.X: [[ 0. 0. ]\n",
7211-
" [ 0. 1. ]\n",
7212-
" [ 1. 0. ]\n",
7213-
" [ 1. 1. ]\n",
7214-
" [-0.90924339 -0.15823458]\n",
7215-
" [-0.20581711 -0.48124909]\n",
7216-
" [ 0.94974117 -0.94631272]\n",
7217-
" [-0.12095571 0.06383589]\n",
7218-
" [-0.66278702 0.17431637]\n",
7219-
" [ 0.28200844 0.93001011]\n",
7220-
" [ 0.47878812 0.65321058]]\n",
7221-
"S.y: [0. 1. 1. 2. 0.85176172 0.27396137\n",
7222-
" 1.79751605 0.01870531 0.46967283 0.94444757 0.65592212]\n"
7223-
]
7224-
}
7225-
],
7197+
"outputs": [],
72267198
"source": [
72277199
"import numpy as np\n",
72287200
"from spotpython.fun.objectivefunctions import Analytical\n",
@@ -7256,25 +7228,9 @@
72567228
},
72577229
{
72587230
"cell_type": "code",
7259-
"execution_count": 2,
7231+
"execution_count": null,
72607232
"metadata": {},
7261-
"outputs": [
7262-
{
7263-
"name": "stderr",
7264-
"output_type": "stream",
7265-
"text": [
7266-
"Seed set to 123\n"
7267-
]
7268-
},
7269-
{
7270-
"name": "stdout",
7271-
"output_type": "stream",
7272-
"text": [
7273-
"Moving TENSORBOARD_PATH: runs/ to TENSORBOARD_PATH_OLD: runs_OLD/runs_2025_01_12_10_59_57\n",
7274-
"Created spot_tensorboard_path: runs/spot_logs/00_p040025_2025-01-12_10-59-57 for SummaryWriter()\n"
7275-
]
7276-
}
7277-
],
7233+
"outputs": [],
72787234
"source": [
72797235
"import numpy as np\n",
72807236
"from spotpython.fun import Analytical\n",
@@ -7304,35 +7260,9 @@
73047260
},
73057261
{
73067262
"cell_type": "code",
7307-
"execution_count": 3,
7263+
"execution_count": null,
73087264
"metadata": {},
7309-
"outputs": [
7310-
{
7311-
"name": "stderr",
7312-
"output_type": "stream",
7313-
"text": [
7314-
"Seed set to 123\n"
7315-
]
7316-
},
7317-
{
7318-
"name": "stdout",
7319-
"output_type": "stream",
7320-
"text": [
7321-
"Design matrix: [[ 0.1 0.2 ]\n",
7322-
" [ 0.3 0.4 ]\n",
7323-
" [ 0.86352963 0.7892358 ]\n",
7324-
" [-0.24407197 -0.83687436]\n",
7325-
" [ 0.36481882 0.8375811 ]\n",
7326-
" [ 0.415331 0.54468512]\n",
7327-
" [-0.56395091 -0.77797854]\n",
7328-
" [-0.90259409 -0.04899292]\n",
7329-
" [-0.16484832 0.35724741]\n",
7330-
" [ 0.05170659 0.07401196]\n",
7331-
" [-0.78548145 -0.44638164]\n",
7332-
" [ 0.64017497 -0.30363301]]\n"
7333-
]
7334-
}
7335-
],
7265+
"outputs": [],
73367266
"source": [
73377267
"import numpy as np\n",
73387268
"from spotpython.fun import Analytical\n",
@@ -7361,40 +7291,9 @@
73617291
},
73627292
{
73637293
"cell_type": "code",
7364-
"execution_count": 4,
7294+
"execution_count": null,
73657295
"metadata": {},
7366-
"outputs": [
7367-
{
7368-
"name": "stderr",
7369-
"output_type": "stream",
7370-
"text": [
7371-
"Seed set to 123\n"
7372-
]
7373-
},
7374-
{
7375-
"name": "stdout",
7376-
"output_type": "stream",
7377-
"text": [
7378-
"S.X: [[ 0. 0. ]\n",
7379-
" [ 0. 1. ]\n",
7380-
" [ 1. 0. ]\n",
7381-
" [ 1. 1. ]\n",
7382-
" [ 0.86352963 0.7892358 ]\n",
7383-
" [-0.24407197 -0.83687436]\n",
7384-
" [ 0.36481882 0.8375811 ]\n",
7385-
" [ 0.415331 0.54468512]\n",
7386-
" [-0.56395091 -0.77797854]\n",
7387-
" [-0.90259409 -0.04899292]\n",
7388-
" [-0.16484832 0.35724741]\n",
7389-
" [ 0.05170659 0.07401196]\n",
7390-
" [-0.78548145 -0.44638164]\n",
7391-
" [ 0.64017497 -0.30363301]]\n",
7392-
"S.y: [0. 1. 1. 2. 1.36857656 0.75992983\n",
7393-
" 0.83463487 0.46918172 0.92329124 0.8170764 0.15480068 0.00815134\n",
7394-
" 0.81623768 0.502017 ]\n"
7395-
]
7396-
}
7397-
],
7296+
"outputs": [],
73987297
"source": [
73997298
"import numpy as np\n",
74007299
"from spotpython.fun.objectivefunctions import Analytical\n",
@@ -7526,6 +7425,217 @@
75267425
" # Implement the logic to generate a filename\n",
75277426
" return f\"{prefix}_experiment.pkl\""
75287427
]
7428+
},
7429+
{
7430+
"cell_type": "markdown",
7431+
"metadata": {},
7432+
"source": [
7433+
"## transform_hyper_parameter_values()"
7434+
]
7435+
},
7436+
{
7437+
"cell_type": "code",
7438+
"execution_count": 1,
7439+
"metadata": {},
7440+
"outputs": [
7441+
{
7442+
"data": {
7443+
"text/plain": [
7444+
"{'max_depth': 4, 'leaf_prediction': 'mean'}"
7445+
]
7446+
},
7447+
"execution_count": 1,
7448+
"metadata": {},
7449+
"output_type": "execute_result"
7450+
}
7451+
],
7452+
"source": [
7453+
"from spotpython.utils.transform import transform_hyper_parameter_values\n",
7454+
"fun_control = {\n",
7455+
" \"core_model_hyper_dict\": {\n",
7456+
" \"leaf_prediction\": {\n",
7457+
" \"type\": \"factor\",\n",
7458+
" \"transform\": \"None\",\n",
7459+
" \"default\": \"mean\",\n",
7460+
" \"levels\": [\"mean\", \"model\", \"adaptive\"],\n",
7461+
" \"core_model_parameter_type\": \"str\"\n",
7462+
" },\n",
7463+
" \"max_depth\": {\n",
7464+
" \"type\": \"int\",\n",
7465+
" \"default\": 20,\n",
7466+
" \"transform\": \"transform_power_2\",\n",
7467+
" \"lower\": 2,\n",
7468+
" \"upper\": 20}\n",
7469+
" }\n",
7470+
" }\n",
7471+
"hyper_parameter_values = {\n",
7472+
" 'max_depth': 2,\n",
7473+
" 'leaf_prediction': 'mean'}\n",
7474+
"transform_hyper_parameter_values(fun_control, hyper_parameter_values)"
7475+
]
7476+
},
7477+
{
7478+
"cell_type": "code",
7479+
"execution_count": 3,
7480+
"metadata": {},
7481+
"outputs": [
7482+
{
7483+
"data": {
7484+
"text/plain": [
7485+
"{'l1': 4,\n",
7486+
" 'epochs': 8,\n",
7487+
" 'batch_size': 16,\n",
7488+
" 'act_fn': 'ReLU',\n",
7489+
" 'optimizer': 'SGD',\n",
7490+
" 'dropout_prob': 0.01,\n",
7491+
" 'lr_mult': 1.0,\n",
7492+
" 'patience': 8,\n",
7493+
" 'batch_norm': 0,\n",
7494+
" 'initialization': 'Default'}"
7495+
]
7496+
},
7497+
"execution_count": 3,
7498+
"metadata": {},
7499+
"output_type": "execute_result"
7500+
}
7501+
],
7502+
"source": [
7503+
"from spotpython.utils.transform import transform_hyper_parameter_values\n",
7504+
"fun_control = {\n",
7505+
" \"core_model_hyper_dict\": {\n",
7506+
" \"l1\": {\n",
7507+
" \"type\": \"int\",\n",
7508+
" \"default\": 3,\n",
7509+
" \"transform\": \"transform_power_2_int\",\n",
7510+
" \"lower\": 3,\n",
7511+
" \"upper\": 8\n",
7512+
" },\n",
7513+
" \"epochs\": {\n",
7514+
" \"type\": \"int\",\n",
7515+
" \"default\": 4,\n",
7516+
" \"transform\": \"transform_power_2_int\",\n",
7517+
" \"lower\": 4,\n",
7518+
" \"upper\": 9\n",
7519+
" },\n",
7520+
" \"batch_size\": {\n",
7521+
" \"type\": \"int\",\n",
7522+
" \"default\": 4,\n",
7523+
" \"transform\": \"transform_power_2_int\",\n",
7524+
" \"lower\": 1,\n",
7525+
" \"upper\": 4\n",
7526+
" },\n",
7527+
" \"act_fn\": {\n",
7528+
" \"levels\": [\n",
7529+
" \"Sigmoid\",\n",
7530+
" \"Tanh\",\n",
7531+
" \"ReLU\",\n",
7532+
" \"LeakyReLU\",\n",
7533+
" \"ELU\",\n",
7534+
" \"Swish\"\n",
7535+
" ],\n",
7536+
" \"type\": \"factor\",\n",
7537+
" \"default\": \"ReLU\",\n",
7538+
" \"transform\": \"None\",\n",
7539+
" \"class_name\": \"spotpython.torch.activation\",\n",
7540+
" \"core_model_parameter_type\": \"instance()\",\n",
7541+
" \"lower\": 0,\n",
7542+
" \"upper\": 5\n",
7543+
" },\n",
7544+
" \"optimizer\": {\n",
7545+
" \"levels\": [\n",
7546+
" \"Adadelta\",\n",
7547+
" \"Adagrad\",\n",
7548+
" \"Adam\",\n",
7549+
" \"AdamW\",\n",
7550+
" \"SparseAdam\",\n",
7551+
" \"Adamax\",\n",
7552+
" \"ASGD\",\n",
7553+
" \"NAdam\",\n",
7554+
" \"RAdam\",\n",
7555+
" \"RMSprop\",\n",
7556+
" \"Rprop\",\n",
7557+
" \"SGD\"\n",
7558+
" ],\n",
7559+
" \"type\": \"factor\",\n",
7560+
" \"default\": \"SGD\",\n",
7561+
" \"transform\": \"None\",\n",
7562+
" \"class_name\": \"torch.optim\",\n",
7563+
" \"core_model_parameter_type\": \"str\",\n",
7564+
" \"lower\": 0,\n",
7565+
" \"upper\": 11\n",
7566+
" },\n",
7567+
" \"dropout_prob\": {\n",
7568+
" \"type\": \"float\",\n",
7569+
" \"default\": 0.01,\n",
7570+
" \"transform\": \"None\",\n",
7571+
" \"lower\": 0.0,\n",
7572+
" \"upper\": 0.25\n",
7573+
" },\n",
7574+
" \"lr_mult\": {\n",
7575+
" \"type\": \"float\",\n",
7576+
" \"default\": 1.0,\n",
7577+
" \"transform\": \"None\",\n",
7578+
" \"lower\": 0.1,\n",
7579+
" \"upper\": 10.0\n",
7580+
" },\n",
7581+
" \"patience\": {\n",
7582+
" \"type\": \"int\",\n",
7583+
" \"default\": 2,\n",
7584+
" \"transform\": \"transform_power_2_int\",\n",
7585+
" \"lower\": 2,\n",
7586+
" \"upper\": 6\n",
7587+
" },\n",
7588+
" \"batch_norm\": {\n",
7589+
" \"levels\": [\n",
7590+
" 0,\n",
7591+
" 1\n",
7592+
" ],\n",
7593+
" \"type\": \"factor\",\n",
7594+
" \"default\": 0,\n",
7595+
" \"transform\": \"None\",\n",
7596+
" \"core_model_parameter_type\": \"bool\",\n",
7597+
" \"lower\": 0,\n",
7598+
" \"upper\": 1\n",
7599+
" },\n",
7600+
" \"initialization\": {\n",
7601+
" \"levels\": [\n",
7602+
" \"Default\",\n",
7603+
" \"kaiming_uniform\",\n",
7604+
" \"kaiming_normal\",\n",
7605+
" \"xavier_uniform\",\n",
7606+
" \"xavier_normal\"\n",
7607+
" ],\n",
7608+
" \"type\": \"factor\",\n",
7609+
" \"default\": \"Default\",\n",
7610+
" \"transform\": \"None\",\n",
7611+
" \"core_model_parameter_type\": \"str\",\n",
7612+
" \"lower\": 0,\n",
7613+
" \"upper\": 4\n",
7614+
" }\n",
7615+
" }\n",
7616+
"}\n",
7617+
"\n",
7618+
"hyper_parameter_values = {\n",
7619+
" 'l1': 2,\n",
7620+
" 'epochs': 3,\n",
7621+
" 'batch_size': 4,\n",
7622+
" 'act_fn': 'ReLU',\n",
7623+
" 'optimizer': 'SGD',\n",
7624+
" 'dropout_prob': 0.01,\n",
7625+
" 'lr_mult': 1.0,\n",
7626+
" 'patience': 3,\n",
7627+
" 'batch_norm': 0,\n",
7628+
" 'initialization': 'Default', \n",
7629+
" }\n",
7630+
"transform_hyper_parameter_values(fun_control, hyper_parameter_values)\n"
7631+
]
7632+
},
7633+
{
7634+
"cell_type": "code",
7635+
"execution_count": null,
7636+
"metadata": {},
7637+
"outputs": [],
7638+
"source": []
75297639
}
75307640
],
75317641
"metadata": {

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.22.7"
10+
version = "0.23.0_alpha"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

0 commit comments

Comments
 (0)