-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Github Actions
committed
Sep 25, 2024
1 parent
699b59c
commit b12a47d
Showing
636 changed files
with
11,138 additions
and
306 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/1_basics/1_quadratic_function.doctree
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/1_basics/3_ask_and_tell.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+1.24 KB
(110%)
development/.doctrees/examples/1_basics/sg_execution_times.doctree
Binary file not shown.
Binary file modified
BIN
-384 Bytes
(99%)
development/.doctrees/examples/2_multi_fidelity/1_mlp_epochs.doctree
Binary file not shown.
Binary file modified
BIN
-398 Bytes
(98%)
development/.doctrees/examples/2_multi_fidelity/2_sgd_datasets.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/2_multi_fidelity/3_specify_HB_via_total_budget.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/2_multi_fidelity/sg_execution_times.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/3_multi_objective/1_schaffer.doctree
Binary file not shown.
Binary file modified
BIN
-835 Bytes
(97%)
development/.doctrees/examples/3_multi_objective/2_parego.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/3_multi_objective/sg_execution_times.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/5_commandline/1_call_target_function_script.doctree
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/.doctrees/examples/5_commandline/sg_execution_times.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/063faf88baea73dba8e7341bd337a200/1_quadratic_function.zip
Binary file not shown.
Binary file added
BIN
+7.63 KB
development/_downloads/0a831549e68486c42c2e545929f5d4e3/8_warmstart.zip
Binary file not shown.
84 changes: 84 additions & 0 deletions
84
development/_downloads/18ed294c2c5b262fc9157601c6226331/8_warmstart.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
""" | ||
Warmstarting SMAC | ||
====================================== | ||
With the ask and tell interface, we can support warmstarting SMAC. We can communicate rich | ||
information about the previous trials to SMAC using `TrialInfo` and `TrialValue` instances. | ||
For more details on ask and tell consult `advanced_usage/5_ask_and_tell`. | ||
""" | ||
from __future__ import annotations | ||
|
||
from smac.scenario import Scenario | ||
from smac.facade import HyperparameterOptimizationFacade | ||
from ConfigSpace import Configuration, ConfigurationSpace, Float | ||
from smac.runhistory.dataclasses import TrialValue, TrialInfo | ||
|
||
|
||
class Rosenbrock2D: | ||
@property | ||
def configspace(self) -> ConfigurationSpace: | ||
cs = ConfigurationSpace(seed=0) | ||
x0 = Float("x0", (-5, 10), default=-3) | ||
x1 = Float("x1", (-5, 10), default=-4) | ||
cs.add([x0, x1]) | ||
|
||
return cs | ||
|
||
def evaluate(self, config: Configuration, seed: int = 0) -> float: | ||
"""The 2-dimensional Rosenbrock function as a toy model. | ||
The Rosenbrock function is well know in the optimization community and | ||
often serves as a toy problem. It can be defined for arbitrary | ||
dimensions. The minimium is always at x_i = 1 with a function value of | ||
zero. All input parameters are continuous. The search domain for | ||
all x's is the interval [-5, 10]. | ||
""" | ||
x1 = config["x0"] | ||
x2 = config["x1"] | ||
|
||
cost = 100.0 * (x2 - x1**2.0) ** 2.0 + (1 - x1) ** 2.0 | ||
return cost | ||
|
||
|
||
if __name__ == "__main__": | ||
SEED = 12345 | ||
task = Rosenbrock2D() | ||
|
||
# Previous evaluations | ||
# X vectors need to be connected to the configuration space | ||
configurations = [ | ||
Configuration(task.configspace, {'x0':1, 'x1':2}), | ||
Configuration(task.configspace, {'x0':-1, 'x1':3}), | ||
Configuration(task.configspace, {'x0':5, 'x1':5}), | ||
] | ||
costs = [task.evaluate(c, seed=SEED) for c in configurations] | ||
|
||
# Define optimization problem and budget | ||
scenario = Scenario(task.configspace, deterministic=False, n_trials=30) | ||
intensifier = HyperparameterOptimizationFacade.get_intensifier(scenario, max_config_calls=1) | ||
smac = HyperparameterOptimizationFacade( | ||
scenario, | ||
task.evaluate, | ||
intensifier=intensifier, | ||
overwrite=True, | ||
|
||
# Modify the initial design to use our custom initial design | ||
initial_design=HyperparameterOptimizationFacade.get_initial_design( | ||
scenario, | ||
n_configs=0, # Do not use the default initial design | ||
additional_configs=configurations # Use the configurations previously evaluated as initial design | ||
# This only passes the configurations but not the cost! | ||
# So in order to actually use the custom, pre-evaluated initial design | ||
# we need to tell those trials, like below. | ||
) | ||
) | ||
|
||
# Convert previously evaluated configurations into TrialInfo and TrialValue instances to pass to SMAC | ||
trial_infos = [TrialInfo(config=c, seed=SEED) for c in configurations] | ||
trial_values = [TrialValue(cost=c) for c in costs] | ||
|
||
# Warmstart SMAC with the trial information and values | ||
for info, value in zip(trial_infos, trial_values): | ||
smac.tell(info, value) | ||
|
||
# Optimize as usual | ||
smac.optimize() |
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/1e0c944ace9c062b0d0e5384a117c0a9/2_sgd_datasets.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/27a00d8d416eb0656332c9b4aa2106f2/1_schaffer.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/3e10c4404a224fa5a1f640ee1420cee0/2_svm_cv.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/49ed3f530b360a5f903030f84d3fbc00/1_call_target_function_script.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/5f7af4d241173fd9f4d4445891bb8995/1_mlp_epochs.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/6d5784621a777b1b2116cd9e73c2fbb3/3_ask_and_tell.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/8e591d0775f87f99196616171f815f56/4_callback.zip
Binary file not shown.
Binary file modified
BIN
+3.41 KB
(110%)
development/_downloads/bc82bea3a5dd7bdba60b65220891d9e5/examples_python.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/c3274eae6f91897cdd95549b09a79a4e/3_specify_HB_via_total_budget.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/d198a13b3da9ac20be16998a6bf61983/6_priors.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/d7d5ff2dd061059c0d350ef36825b902/5_continue.zip
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
development/_downloads/ed1a42934b5fbe7816cabd752552cf37/2_parego.zip
Binary file not shown.
Binary file modified
BIN
+4.23 KB
(110%)
development/_downloads/fb625db3c50d423b1b7881136ffdeec8/examples_jupyter.zip
Binary file not shown.
43 changes: 43 additions & 0 deletions
43
development/_downloads/fdb3c00a02e05344ce4cd89d981456af/8_warmstart.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Warmstarting SMAC\n\nWith the ask and tell interface, we can support warmstarting SMAC. We can communicate rich\ninformation about the previous trials to SMAC using `TrialInfo` and `TrialValue` instances.\nFor more details on ask and tell consult `advanced_usage/5_ask_and_tell`.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from __future__ import annotations\n\nfrom smac.scenario import Scenario\nfrom smac.facade import HyperparameterOptimizationFacade\nfrom ConfigSpace import Configuration, ConfigurationSpace, Float\nfrom smac.runhistory.dataclasses import TrialValue, TrialInfo\n\n\nclass Rosenbrock2D:\n @property\n def configspace(self) -> ConfigurationSpace:\n cs = ConfigurationSpace(seed=0)\n x0 = Float(\"x0\", (-5, 10), default=-3)\n x1 = Float(\"x1\", (-5, 10), default=-4)\n cs.add([x0, x1])\n\n return cs\n\n def evaluate(self, config: Configuration, seed: int = 0) -> float:\n \"\"\"The 2-dimensional Rosenbrock function as a toy model.\n The Rosenbrock function is well know in the optimization community and\n often serves as a toy problem. It can be defined for arbitrary\n dimensions. The minimium is always at x_i = 1 with a function value of\n zero. All input parameters are continuous. The search domain for\n all x's is the interval [-5, 10].\n \"\"\"\n x1 = config[\"x0\"]\n x2 = config[\"x1\"]\n\n cost = 100.0 * (x2 - x1**2.0) ** 2.0 + (1 - x1) ** 2.0\n return cost\n\n\nif __name__ == \"__main__\":\n SEED = 12345\n task = Rosenbrock2D()\n\n # Previous evaluations\n # X vectors need to be connected to the configuration space\n configurations = [\n Configuration(task.configspace, {'x0':1, 'x1':2}),\n Configuration(task.configspace, {'x0':-1, 'x1':3}),\n Configuration(task.configspace, {'x0':5, 'x1':5}),\n ]\n costs = [task.evaluate(c, seed=SEED) for c in configurations]\n\n # Define optimization problem and budget\n scenario = Scenario(task.configspace, deterministic=False, n_trials=30)\n intensifier = HyperparameterOptimizationFacade.get_intensifier(scenario, max_config_calls=1)\n smac = HyperparameterOptimizationFacade(\n scenario,\n task.evaluate,\n intensifier=intensifier,\n overwrite=True,\n\n # Modify the initial design to use our custom initial design\n initial_design=HyperparameterOptimizationFacade.get_initial_design(\n scenario, \n n_configs=0, # Do not use the default initial design\n additional_configs=configurations # Use the configurations previously evaluated as initial design\n # This only passes the configurations but not the cost!\n # So in order to actually use the custom, pre-evaluated initial design\n # we need to tell those trials, like below.\n )\n )\n\n # Convert previously evaluated configurations into TrialInfo and TrialValue instances to pass to SMAC\n trial_infos = [TrialInfo(config=c, seed=SEED) for c in configurations]\n trial_values = [TrialValue(cost=c) for c in costs]\n\n # Warmstart SMAC with the trial information and values\n for info, value in zip(trial_infos, trial_values):\n smac.tell(info, value)\n\n # Optimize as usual\n smac.optimize()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.15" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.