-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,157 additions
and
588 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
docs/examples/images/sphx_glr_plot_experimental_design_001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ples/images/sphx_glr_plot_from_serial_to_parallel_hyperparameter_search_001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
docs/examples/images/sphx_glr_plot_profile_worker_utilization_001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
docs/examples/images/thumb/sphx_glr_plot_experimental_design_thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ges/thumb/sphx_glr_plot_from_serial_to_parallel_hyperparameter_search_thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
docs/examples/images/thumb/sphx_glr_plot_profile_worker_utilization_thumb.png
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
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,115 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Profile the Worker Utilization\n\n**Author(s)**: Romain Egele.\n\nThis example demonstrates how to generate points from standard experimental designs (e.g., random, grid, lhs).\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from deephyper.analysis._matplotlib import update_matplotlib_rc\n\nupdate_matplotlib_rc()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"First we define the hyperparameter search space.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from deephyper.problem import HpProblem\n\n\nproblem = HpProblem()\nproblem.add_hyperparameter((0.0001, 100.0, \"log-uniform\"), \"x\")\nproblem.add_hyperparameter((0.0, 100.0), \"y\")\nproblem.add_hyperparameter([1, 2, 3], \"z\")\nproblem\nproblem" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Then we define the black-box function to optimize.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def run(job):\n config = job.parameters\n objective = config[\"x\"] + config[\"y\"]\n return objective" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Then we define the search. In this example, we use the `ExperimentalDesignSearch` class to generate points from a grid design. The `Evaluator` can also be used with this class to parallelize evalutions.\nNote that `n_points` and `max_evals` take the same value here.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from deephyper.search.hps import ExperimentalDesignSearch\n\n\nmax_evals = 200\nsearch = ExperimentalDesignSearch(problem, run, n_points=max_evals, design=\"grid\")\nresults = search.search(max_evals)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Finally, we plot the results from the collected DataFrame.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n\n\nfig, ax = plt.subplots()\nax.scatter(results[\"p:x\"], results[\"p:y\"], c=results[\"p:z\"], alpha=0.3)\nax.set_xscale(\"log\")\nplt.xlabel(\"x\")\nplt.ylabel(\"y\")\nplt.show()" | ||
] | ||
} | ||
], | ||
"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.11.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
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,57 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Profile the Worker Utilization | ||
============================== | ||
**Author(s)**: Romain Egele. | ||
This example demonstrates how to generate points from standard experimental designs (e.g., random, grid, lhs). | ||
""" | ||
|
||
|
||
from deephyper.analysis._matplotlib import update_matplotlib_rc | ||
|
||
update_matplotlib_rc() | ||
|
||
# %% | ||
# First we define the hyperparameter search space. | ||
from deephyper.problem import HpProblem | ||
|
||
|
||
problem = HpProblem() | ||
problem.add_hyperparameter((0.0001, 100.0, "log-uniform"), "x") | ||
problem.add_hyperparameter((0.0, 100.0), "y") | ||
problem.add_hyperparameter([1, 2, 3], "z") | ||
problem | ||
problem | ||
|
||
|
||
# %% | ||
# Then we define the black-box function to optimize. | ||
def run(job): | ||
config = job.parameters | ||
objective = config["x"] + config["y"] | ||
return objective | ||
|
||
|
||
# %% | ||
# Then we define the search. In this example, we use the `ExperimentalDesignSearch` class to generate points from a grid design. The `Evaluator` can also be used with this class to parallelize evalutions. | ||
# Note that `n_points` and `max_evals` take the same value here. | ||
from deephyper.search.hps import ExperimentalDesignSearch | ||
|
||
|
||
max_evals = 200 | ||
search = ExperimentalDesignSearch(problem, run, n_points=max_evals, design="grid") | ||
results = search.search(max_evals) | ||
|
||
# %% | ||
# Finally, we plot the results from the collected DataFrame. | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
fig, ax = plt.subplots() | ||
ax.scatter(results["p:x"], results["p:y"], c=results["p:z"], alpha=0.3) | ||
ax.set_xscale("log") | ||
plt.xlabel("x") | ||
plt.ylabel("y") | ||
plt.show() |
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 @@ | ||
7f69999a456e564a57a3f22168030ff9 |
Oops, something went wrong.