Skip to content

Commit 852c84e

Browse files
v0.5.2
tensorboard logging improved
1 parent 0a3be72 commit 852c84e

89 files changed

Lines changed: 1835 additions & 2084 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/01_spot_intro.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
<li class="sidebar-item">
249249
<div class="sidebar-item-container">
250250
<a href="./13_spot_hpt_river.html" class="sidebar-item-text sidebar-link">
251-
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">HPT: River</span></span></a>
251+
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">River Hyperparameter Tuning with SPOT HATR</span></span></a>
252252
</div>
253253
</li>
254254
<li class="sidebar-item">
@@ -344,8 +344,8 @@ <h1 class="title"><span id="sec-hyperparameter-tuning" class="quarto-section-ide
344344
<p>Hyperparameter tuning is an important, but often difficult and computationally intensive task. Changing the architecture of a neural network or the learning rate of an optimizer can have a significant impact on the performance.</p>
345345
<p>The goal of hyperparameter tuning is to optimize the hyperparameters in a way that improves the performance of the machine learning or deep learning model. The simplest, but also most computationally expensive, approach uses manual search (or trial-and-error <span class="citation" data-cites="Meignan:2015vp">(<a href="references.html#ref-Meignan:2015vp" role="doc-biblioref">Meignan et al. 2015</a>)</span>). Commonly encountered is simple random search, i.e., random and repeated selection of hyperparameters for evaluation, and lattice search (“grid search”). In addition, methods that perform directed search and other model-free algorithms, i.e., algorithms that do not explicitly rely on a model, e.g., evolution strategies <span class="citation" data-cites="Bart13j">(<a href="references.html#ref-Bart13j" role="doc-biblioref">Bartz-Beielstein et al. 2014</a>)</span> or pattern search <span class="citation" data-cites="Torczon00">(<a href="references.html#ref-Torczon00" role="doc-biblioref">Lewis, Torczon, and Trosset 2000</a>)</span> play an important role. Also, “hyperband”, i.e., a multi-armed bandit strategy that dynamically allocates resources to a set of random configurations and uses successive bisections to stop configurations with poor performance <span class="citation" data-cites="Li16a">(<a href="references.html#ref-Li16a" role="doc-biblioref">Li et al. 2016</a>)</span>, is very common in hyperparameter tuning. The most sophisticated and efficient approaches are the Bayesian optimization and surrogate model based optimization methods, which are based on the optimization of cost functions determined by simulations or experiments.</p>
346346
<p>We consider below a surrogate model based optimization-based hyperparameter tuning approach based on the Python version of the SPOT (“Sequential Parameter Optimization Toolbox”) <span class="citation" data-cites="BLP05">(<a href="references.html#ref-BLP05" role="doc-biblioref">Bartz-Beielstein, Lasarczyk, and Preuss 2005</a>)</span>, which is suitable for situations where only limited resources are available. This may be due to limited availability and cost of hardware, or due to the fact that confidential data may only be processed locally, e.g., due to legal requirements. Furthermore, in our approach, the understanding of algorithms is seen as a key tool for enabling transparency and explainability. This can be enabled, for example, by quantifying the contribution of machine learning and deep learning components (nodes, layers, split decisions, activation functions, etc.). Understanding the importance of hyperparameters and the interactions between multiple hyperparameters plays a major role in the interpretability and explainability of machine learning models. SPOT provides statistical tools for understanding hyperparameters and their interactions. Last but not least, it should be noted that the SPOT software code is available in the open source <code>spotPython</code> package on github<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>, allowing replicability of the results. This tutorial descries the Python variant of SPOT, which is called <code>spotPython</code>. The R implementation is described in <span class="citation" data-cites="bart21i">Bartz et al. (<a href="references.html#ref-bart21i" role="doc-biblioref">2022</a>)</span>. SPOT is an established open source software that has been maintained for more than 15 years <span class="citation" data-cites="BLP05">(<a href="references.html#ref-BLP05" role="doc-biblioref">Bartz-Beielstein, Lasarczyk, and Preuss 2005</a>)</span> <span class="citation" data-cites="bart21i">(<a href="references.html#ref-bart21i" role="doc-biblioref">Bartz et al. 2022</a>)</span>.</p>
347-
<p>This tutorial is structured as follows. The concept of the hyperparameter tuning software <code>spotPython</code> is described in <a href="#sec-spot"><span>Section&nbsp;1.1</span></a>. <a href="14_spot_ray_hpt_torch_cifar10.html"><span>Chapter&nbsp;12</span></a> describes the execution of the example from the tutorial “Hyperparameter Tuning with Ray Tune” <span class="citation" data-cites="pyto23a">(<a href="references.html#ref-pyto23a" role="doc-biblioref">PyTorch 2023</a>)</span>. The integration of <code>spotPython</code> into the <code>PyTorch</code> training workflow is described in detail in the following sections. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-setup-14"><span>Section&nbsp;12.1</span></a> describes the setup of the tuners. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-data-loading-14"><span>Section&nbsp;12.3</span></a> describes the data loading. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-selection-of-the-algorithm-14"><span>Section&nbsp;12.5</span></a> describes the model to be tuned. The search space is introduced in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-search-space-14"><span>Section&nbsp;12.5.3</span></a>. Optimizers are presented in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-optimizers-14"><span>Section&nbsp;12.6.1</span></a>. How to split the data in train, validation, and test sets is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-data-splitting-14"><span>Section&nbsp;12.7.1</span></a>. The selection of the loss function and metrics is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-loss-functions-14"><span>Section&nbsp;12.7.5</span></a>. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-prepare-spot-call-14"><span>Section&nbsp;12.8.1</span></a> describes the preparation of the <code>spotPython</code> call. The objective function is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-the-objective-function-14"><span>Section&nbsp;12.8.2</span></a>. How to use results from previous runs and default hyperparameter configurations is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-default-hyperparameters"><span>Section&nbsp;12.8.3</span></a>. Starting the tuner is shown in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-call-the-hyperparameter-tuner-14"><span>Section&nbsp;12.8.4</span></a>. TensorBoard can be used to visualize the results as shown in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-tensorboard-14"><span>Section&nbsp;12.9</span></a>. Results are discussed and explained in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-results-14"><span>Section&nbsp;12.10</span></a>.</p>
348-
<p><span class="quarto-unresolved-ref">?sec-hyperparameter-tuning-lightning-30</span> shows the integration of <code>spotPython</code> into the <code>PyTorch Lightning</code> training workflow.</p>
347+
<p>This document is structured as follows. The concept of the hyperparameter tuning software <code>spotPython</code> is described in <a href="#sec-spot"><span>Section&nbsp;1.1</span></a>. <a href="14_spot_ray_hpt_torch_cifar10.html"><span>Chapter&nbsp;12</span></a> describes the execution of the example from the tutorial “Hyperparameter Tuning with Ray Tune” <span class="citation" data-cites="pyto23a">(<a href="references.html#ref-pyto23a" role="doc-biblioref">PyTorch 2023</a>)</span>. The integration of <code>spotPython</code> into the <code>PyTorch</code> training workflow is described in detail in the following sections. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-setup-14"><span>Section&nbsp;12.1</span></a> describes the setup of the tuners. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-data-loading-14"><span>Section&nbsp;12.3</span></a> describes the data loading. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-selection-of-the-algorithm-14"><span>Section&nbsp;12.5</span></a> describes the model to be tuned. The search space is introduced in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-search-space-14"><span>Section&nbsp;12.5.3</span></a>. Optimizers are presented in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-optimizers-14"><span>Section&nbsp;12.6.1</span></a>. How to split the data in train, validation, and test sets is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-data-splitting-14"><span>Section&nbsp;12.7.1</span></a>. The selection of the loss function and metrics is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-loss-functions-14"><span>Section&nbsp;12.7.5</span></a>. <a href="14_spot_ray_hpt_torch_cifar10.html#sec-prepare-spot-call-14"><span>Section&nbsp;12.8.1</span></a> describes the preparation of the <code>spotPython</code> call. The objective function is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-the-objective-function-14"><span>Section&nbsp;12.8.2</span></a>. How to use results from previous runs and default hyperparameter configurations is described in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-default-hyperparameters"><span>Section&nbsp;12.8.3</span></a>. Starting the tuner is shown in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-call-the-hyperparameter-tuner-14"><span>Section&nbsp;12.8.4</span></a>. TensorBoard can be used to visualize the results as shown in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-tensorboard-14"><span>Section&nbsp;12.9</span></a>. Results are discussed and explained in <a href="14_spot_ray_hpt_torch_cifar10.html#sec-results-14"><span>Section&nbsp;12.10</span></a>.</p>
348+
<p><a href="31_spot_lightning_csv.html"><span>Chapter&nbsp;17</span></a> shows the integration of <code>spotPython</code> into the <code>PyTorch Lightning</code> training workflow.</p>
349349
<p><a href="14_spot_ray_hpt_torch_cifar10.html#sec-summary"><span>Section&nbsp;12.11</span></a> presents a summary and an outlook.</p>
350350
<div class="callout callout-style-default callout-note callout-titled">
351351
<div class="callout-header d-flex align-content-center">
@@ -430,7 +430,7 @@ <h3 data-number="1.3.1" class="anchored" data-anchor-id="the-objective-function-
430430
<div class="cell" data-execution_count="5">
431431
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>spot_0.run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
432432
<div class="cell-output cell-output-display" data-execution_count="5">
433-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x165088cd0&gt;</code></pre>
433+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x17ee209a0&gt;</code></pre>
434434
</div>
435435
</div>
436436
<div class="cell" data-execution_count="6">
@@ -482,7 +482,7 @@ <h2 data-number="1.4" class="anchored" data-anchor-id="spot-parameters-fun_evals
482482
<p><img src="01_spot_intro_files/figure-html/cell-10-output-2.png" width="600" height="449"></p>
483483
</div>
484484
<div class="cell-output cell-output-display" data-execution_count="9">
485-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x165476770&gt;</code></pre>
485+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x17ef14040&gt;</code></pre>
486486
</div>
487487
</div>
488488
</section>

docs/02_spot_multidim.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
<li class="sidebar-item">
230230
<div class="sidebar-item-container">
231231
<a href="./13_spot_hpt_river.html" class="sidebar-item-text sidebar-link">
232-
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">HPT: River</span></span></a>
232+
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">River Hyperparameter Tuning with SPOT HATR</span></span></a>
233233
</div>
234234
</li>
235235
<li class="sidebar-item">
@@ -385,7 +385,7 @@ <h3 data-number="2.1.1" class="anchored" data-anchor-id="the-objective-function-
385385
</code></pre>
386386
</div>
387387
<div class="cell-output cell-output-display" data-execution_count="3">
388-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x107db9e10&gt;</code></pre>
388+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x105153010&gt;</code></pre>
389389
</div>
390390
</div>
391391
</section>

docs/03_spot_anisotropic.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
<li class="sidebar-item">
229229
<div class="sidebar-item-container">
230230
<a href="./13_spot_hpt_river.html" class="sidebar-item-text sidebar-link">
231-
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">HPT: River</span></span></a>
231+
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">River Hyperparameter Tuning with SPOT HATR</span></span></a>
232232
</div>
233233
</li>
234234
<li class="sidebar-item">
@@ -362,7 +362,7 @@ <h3 data-number="3.1.1" class="anchored" data-anchor-id="the-objective-function-
362362
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
363363
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>spot_2.run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
364364
<div class="cell-output cell-output-display" data-execution_count="3">
365-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x11ff88e80&gt;</code></pre>
365+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x17f884fd0&gt;</code></pre>
366366
</div>
367367
</div>
368368
</section>
@@ -403,7 +403,7 @@ <h2 data-number="3.2" class="anchored" data-anchor-id="example-with-anisotropic-
403403
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> surrogate_control<span class="op">=</span>{<span class="st">"n_theta"</span>: <span class="dv">2</span>})</span>
404404
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a>spot_2_anisotropic.run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
405405
<div class="cell-output cell-output-display" data-execution_count="6">
406-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x12998a440&gt;</code></pre>
406+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x17f97ddb0&gt;</code></pre>
407407
</div>
408408
</div>
409409
<section id="taking-a-look-at-the-theta-values" class="level3" data-number="3.2.1">

docs/04_spot_sklearn_surrogate.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
<li class="sidebar-item">
228228
<div class="sidebar-item-container">
229229
<a href="./13_spot_hpt_river.html" class="sidebar-item-text sidebar-link">
230-
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">HPT: River</span></span></a>
230+
<span class="menu-text"><span class="chapter-number">11</span>&nbsp; <span class="chapter-title">River Hyperparameter Tuning with SPOT HATR</span></span></a>
231231
</div>
232232
</li>
233233
<li class="sidebar-item">
@@ -383,7 +383,7 @@ <h3 data-number="4.1.2" class="anchored" data-anchor-id="running-the-surrogate-m
383383
<div class="cell" data-execution_count="5">
384384
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>spot_2.run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
385385
<div class="cell-output cell-output-display" data-execution_count="5">
386-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x166088be0&gt;</code></pre>
386+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x1378ecd60&gt;</code></pre>
387387
</div>
388388
</div>
389389
</section>
@@ -489,7 +489,7 @@ <h3 data-number="4.2.1" class="anchored" data-anchor-id="gaussianprocessregresso
489489
<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a> surrogate <span class="op">=</span> S_GP)</span>
490490
<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a>spot_2_GP.run()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
491491
<div class="cell-output cell-output-display" data-execution_count="15">
492-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x169e30a60&gt;</code></pre>
492+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x152035c30&gt;</code></pre>
493493
</div>
494494
</div>
495495
<div class="cell" data-execution_count="16">
@@ -501,12 +501,12 @@ <h3 data-number="4.2.1" class="anchored" data-anchor-id="gaussianprocessregresso
501501
<div class="cell" data-execution_count="17">
502502
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>spot_2_GP.print_results()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
503503
<div class="cell-output cell-output-stdout">
504-
<pre><code>min y: 0.39823192160066156
505-
x0: 3.1497263952038743
506-
x1: 2.2738556068234668</code></pre>
504+
<pre><code>min y: 0.39849972196455496
505+
x0: 3.1505666777693304
506+
x1: 2.283036003232931</code></pre>
507507
</div>
508508
<div class="cell-output cell-output-display" data-execution_count="17">
509-
<pre><code>[['x0', 3.1497263952038743], ['x1', 2.2738556068234668]]</code></pre>
509+
<pre><code>[['x0', 3.1505666777693304], ['x1', 2.283036003232931]]</code></pre>
510510
</div>
511511
</div>
512512
</section>
@@ -561,7 +561,7 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="example-one-dimensional-s
561561
<p><img src="04_spot_sklearn_surrogate_files/figure-html/cell-20-output-8.png" width="604" height="449"></p>
562562
</div>
563563
<div class="cell-output cell-output-display" data-execution_count="19">
564-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x169e30130&gt;</code></pre>
564+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x1424c74c0&gt;</code></pre>
565565
</div>
566566
</div>
567567
<section id="results" class="level3" data-number="4.3.1">
@@ -636,23 +636,23 @@ <h2 data-number="4.4" class="anchored" data-anchor-id="example-sklearn-model-gau
636636
<p><img src="04_spot_sklearn_surrogate_files/figure-html/cell-24-output-8.png" width="604" height="449"></p>
637637
</div>
638638
<div class="cell-output cell-output-display" data-execution_count="23">
639-
<pre><code>&lt;spotPython.spot.spot.Spot at 0x1699a26e0&gt;</code></pre>
639+
<pre><code>&lt;spotPython.spot.spot.Spot at 0x1423c7790&gt;</code></pre>
640640
</div>
641641
</div>
642642
<div class="cell" data-execution_count="24">
643643
<div class="sourceCode cell-code" id="cb38"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a>spot_1_GP.print_results()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
644644
<div class="cell-output cell-output-stdout">
645-
<pre><code>min y: 1.9409234127379644e-11
646-
x0: 4.405591234712958e-06</code></pre>
645+
<pre><code>min y: 3.1956657787215835e-10
646+
x0: 1.7876425198348755e-05</code></pre>
647647
</div>
648648
<div class="cell-output cell-output-display" data-execution_count="24">
649-
<pre><code>[['x0', 4.405591234712958e-06]]</code></pre>
649+
<pre><code>[['x0', 1.7876425198348755e-05]]</code></pre>
650650
</div>
651651
</div>
652652
<div class="cell" data-execution_count="25">
653653
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>spot_1_GP.plot_progress(log_y<span class="op">=</span><span class="va">True</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
654654
<div class="cell-output cell-output-display">
655-
<p><img src="04_spot_sklearn_surrogate_files/figure-html/cell-26-output-1.png" width="735" height="243"></p>
655+
<p><img src="04_spot_sklearn_surrogate_files/figure-html/cell-26-output-1.png" width="729" height="243"></p>
656656
</div>
657657
</div>
658658
<div class="cell" data-execution_count="26">
-6 Bytes
Loading
2.17 KB
Loading
10 Bytes
Loading
2.04 KB
Loading
-1.12 KB
Loading
-1.17 KB
Loading

0 commit comments

Comments
 (0)