<blockquote>
  <p>Although I am still not fully understanding the optimization
  algorithm, I feed like it will help me greatly.</p>
</blockquote>

<p>First up, let me briefly explain this part.
Bayesian Optimization methods aim to deal with exploration-exploitation trade off in the <a href="https://en.wikipedia.org/wiki/Multi-armed_bandit" rel="noreferrer">multi-armed bandit problem</a>. In this problem, there is an <em>unknown</em> function, which we can evaluate in any point, but each evaluation costs (direct penalty or opportunity cost), and the goal is to find its maximum using as few trials as possible. Basically, the trade off is this: you know the function in a finite set of points (of which some are good and some are bad), so you can try an area around the current local maximum, hoping to improve it (exploitation), or you can try a completely new area of space, that can potentially be much better or much worse (exploration), or somewhere in between.</p>

<p>Bayesian Optimization methods (e.g. PI, EI, UCB), build a model of the target function using a <a href="https://en.wikipedia.org/wiki/Gaussian_process" rel="noreferrer">Gaussian Process</a> (GP) and at each step choose the most "promising" point based on their GP model (note that "promising" can be defined differently by different particular methods).</p>

<p>Here's an example:</p>

<p><a href="https://i.stack.imgur.com/ksQFy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ksQFy.png" alt="sin(x)*x"></a></p>

<p>The true function is <code>f(x) = x * sin(x)</code> (black curve) on <code>[-10, 10]</code> interval. Red dots represent each trial, red curve is the GP <em>mean</em>, blue curve is the mean plus or minus one <em>standard deviation</em>. 
As you can see, the GP model doesn't match the true function everywhere, but the optimizer fairly quickly identified the "hot" area around <code>-8</code> and started to exploit it.</p>

<blockquote>
  <p>How do I set up the Bayesian Optimization with regards to a deep
  network?</p>
</blockquote>

<p>In this case, the space is defined by (possibly transformed) hyperparameters, usually a multidimensional unit hypercube. </p>

<p>For example, suppose you have three hyperparameters: a learning rate <code>α in [0.001, 0.01]</code>, the regularizer <code>λ in [0.1, 1]</code> (both continuous) and the hidden layer size <code>N in [50..100]</code> (integer). The space for optimization is a 3-dimensional cube <code>[0, 1]*[0, 1]*[0, 1]</code>. Each point <code>(p0, p1, p2)</code> in this cube corresponds to a trinity <code>(α, λ, N)</code> by the following transformation:</p>

<pre><code>p0 -&gt; α = 10**(p0-3)
p1 -&gt; λ = 10**(p1-1)
p2 -&gt; N = int(p2*50 + 50)
</code></pre>

<blockquote>
  <p>What is the function I am trying to optimize? Is it the cost of the
  validation set after N epochs?</p>
</blockquote>

<p>Correct, the target function is neural network validation accuracy. Clearly, each evaluation is expensive, because it requires at least several epochs for training.</p>

<p>Also note that the target function is <em>stochastic</em>, i.e. two evaluations on the same point may slightly differ, but it's not a blocker for Bayesian Optimization, though it obviously increases the uncertainty.</p>

<blockquote>
  <p>Is spearmint a good starting point for this task? Any other
  suggestions for this task?</p>
</blockquote>

<p><a href="https://github.com/kuz/caffe-with-spearmint" rel="noreferrer">spearmint</a> is a good library, you can definitely work with that. I can also recommend <a href="http://hyperopt.github.io/hyperopt/" rel="noreferrer">hyperopt</a>.</p>

<p>In my own research, I ended up writing my own tiny library, basically for two reasons: I wanted to code exact Bayesian method to use (in particular, I found a <a href="https://arxiv.org/pdf/1009.5419.pdf" rel="noreferrer">portfolio strategy</a> of UCB and PI converged faster than anything else, in my case); plus there is another technique that can save up to 50% of training time called <a href="http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf" rel="noreferrer">learning curve prediction</a> (the idea is to skip full learning cycle when the optimizer is confident the model doesn't learn as fast as in other areas). I'm not aware of any library that implements this, so I coded it myself, and in the end it paid off. If you're interested, the code is <a href="https://github.com/maxim5/hyper-engine" rel="noreferrer">on GitHub</a>.</p>
Hyperparameter optimization for Deep Learning Structures using Bayesian Optimization
<p>I have constructed a CLDNN (Convolutional, LSTM, Deep Neural Network) structure for raw signal classification task.</p>

<p>Each training epoch runs for about 90 seconds and the hyperparameters seems to be very difficult to optimize.</p>

<p>I have been research various ways to optimize the hyperparameters (e.g. random or grid search) and found out about Bayesian Optimization.</p>

<p>Although I am still not fully understanding the optimization algorithm, I feed like it will help me greatly.</p>

<p>I would like to ask few questions regarding the optimization task.</p>

<ol>
<li>How do I set up the Bayesian Optimization with regards to a deep network?(What is the cost function we are trying to optimize?)</li>
<li>What is the function I am trying to optimize? Is it the cost of the validation set after N epochs?</li>
<li>Is spearmint a good starting point for this task? Any other suggestions for this task?</li>
</ol>

<p>I would greatly appreciate any insights into this problem.</p>