Answers.Body: <p>There is a Python package called <a href="https://docs.ray.io/en/latest/tune/index.html" rel="nofollow noreferrer">Tune</a> is fairly easy to use, and contains most modern hyperparameter tuning methods such as Bayesian optimization and <a href="https://arxiv.org/abs/1603.06560" rel="nofollow noreferrer">Hyperband</a>. It should interface with both Keras and PyTorch.</p>
  <p>To answer some of your questions:</p>
  <ol>
  <li><p>If you are doing intensive hyperparameter tuning, you need to have three separate datasets: the training set, validation set, and test set. When you train the network, you train on the training set, and evaluate the accuracy metric on the validation set. The validation accuracy is then used to tune the hyperparameters. After you find the best hyperparameters, you then evaluate again on the test set to get the true test accuracy. The reasoning for this is because the act of hyperparameter tuning is itself an optimization procedure, and will suffer from overfitting as well. This is best explained in one of Andrew Ng's <a href="https://www.youtube.com/watch?v=MyBSkmUeIEs&amp;ab_channel=BlitzKim" rel="nofollow noreferrer">video</a>. A more robust way is to do k-fold cross-validation, which I think is the default method of Tune.</p>
  </li>
  <li><p>Yes I think your hyperparameter makes sense. Is <span class="math-container">$\alpha$</span> the learning rate? You can also try to include batchsize from some set, say <span class="math-container">$\{2, 4, 8, 16, ...\}$</span>, given your GPU VRAM.</p>
  </li>
  <li><p>I am not familiar with iRace enough to say it's advantages/disadtanges compared to genetic algorithms. But I know two of the major drawbacks of genetic algorithm is that it doesn't perform well when the number of hyperparameters (or genetic elements) are large, and it has a tedency to converge to local minima.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-30T05:23:06.843Z
Answers.LastActivityDate: 2022-08-30T05:32:50.707Z
Answers.LastEditDate: 2022-08-30T05:32:50.707Z
Answers.UserDisplayName: PeaBrane
Body: <p>I have a fully connected feedforward classifier neural network that uses the leaky ReLU activation function. I would like to apply a state-of-the-art hyperparameter tuning method to my methodology. Currently, the fitness function associated with each parameter setting is a weighted combination of (i) accuracy of both training and test data sets (<span class="math-container">$acc_{tr}$</span> and <span class="math-container">$acc_{ts}$</span>, respectively), (ii) numbers of activated hidden layers (<span class="math-container">$nL$</span>) and their neurons (<span class="math-container">$nN_l$</span>), and (iii) number of epochs (<span class="math-container">$nE$</span>) - length of training. The fitness function is computed as follows:</p>
  <p><span class="math-container">\begin{equation}\label{eqq}
   FF = 0.7 \times (acc_{tr} + acc_{ts}) + 0.1 \times \frac{nL}{10} + 0.1 \times \frac{\sum_{l \in \mathcal{L}} nN_l}{1000} + 0.1 \times \frac{nE}{2000}
  \end{equation}</span></p>
  <p>Note that I have determined the weights in function <span class="math-container">$FF$</span> based on my experimental observations. Potential values for the parameters of this neural network are given in the following table:</p>
  <p><a href="https://i.sstatic.net/TSfJC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TSfJC.png" alt="enter image description here" /></a></p>
  <p><span class="math-container">$\alpha$</span> here is the leakage parameter of the ReLU activation function. Considering that I am new to this field, my questions are as follows:</p>
  <ul>
  <li>Is the weighted fitness function an appropriate one? Should I include both training and test accuracies at the same time? Why?</li>
  <li>Do the potential values make sense for a fully connected feedforward classifier neural network with the leaky ReLU activation function? Are there any other parameters that I have to tune? Please consider that I have developed this neural network using the Keras library.</li>
  <li>The above table also shows the elite configuration. I have found this parameter setting using the iRace package. Do you recommend any other method for hyperparameter tuning in neural networks?</li>
  <li>I have seen many papers use genetic algorithms to tune their parameters. What are the advantages of using a genetic algorithm in comparison to the iRace package (if there is any)?</li>
  </ul>
  <p>Please kindly answer my above questions with supporting scientific references. Also, please let me know if there are any other considerations for the hyperparameter tuning of neural networks. Thank you!</p>
  
Tags: <neural-networks><hyperparameter-optimization>
Title: Hyperparameter tuning methods for neural networks
UserDisplayName: mdslt
ThreadText: # Hyperparameter tuning methods for neural networks
  
  (Asked by: username_0 on 2022-08-30)
  
  I have a fully connected feedforward classifier neural network that uses the leaky ReLU activation function. I would like to apply a state-of-the-art hyperparameter tuning method to my methodology. Currently, the fitness function associated with each parameter setting is a weighted combination of (i) accuracy of both training and test data sets ($acc\_{tr}$ and $acc\_{ts}$, respectively), (ii) numbers of activated hidden layers ($nL$) and their neurons ($nN\_l$), and (iii) number of epochs ($nE$) - length of training. The fitness function is computed as follows:
  
  \begin{equation}\label{eqq}
  FF = 0.7 \times (acc\_{tr} + acc\_{ts}) + 0.1 \times \frac{nL}{10} + 0.1 \times \frac{\sum\_{l \in \mathcal{L}} nN\_l}{1000} + 0.1 \times \frac{nE}{2000}
  \end{equation}
  
  Note that I have determined the weights in function $FF$ based on my experimental observations. Potential values for the parameters of this neural network are given in the following table:
  
  [![enter image description here](https://i.sstatic.net/TSfJC.png)](https://i.sstatic.net/TSfJC.png)
  
  $\alpha$ here is the leakage parameter of the ReLU activation function. Considering that I am new to this field, my questions are as follows:
  
  * Is the weighted fitness function an appropriate one? Should I include both training and test accuracies at the same time? Why?
  * Do the potential values make sense for a fully connected feedforward classifier neural network with the leaky ReLU activation function? Are there any other parameters that I have to tune? Please consider that I have developed this neural network using the Keras library.
  * The above table also shows the elite configuration. I have found this parameter setting using the iRace package. Do you recommend any other method for hyperparameter tuning in neural networks?
  * I have seen many papers use genetic algorithms to tune their parameters. What are the advantages of using a genetic algorithm in comparison to the iRace package (if there is any)?
  
  Please kindly answer my above questions with supporting scientific references. Also, please let me know if there are any other considerations for the hyperparameter tuning of neural networks. Thank you!
  
  **Tags:** neural-networks, hyperparameter-optimization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-30. Score: 2
  
  There is a Python package called [Tune](https://docs.ray.io/en/latest/tune/index.html) is fairly easy to use, and contains most modern hyperparameter tuning methods such as Bayesian optimization and [Hyperband](https://arxiv.org/abs/1603.06560). It should interface with both Keras and PyTorch.
  
  To answer some of your questions:
  
  1. If you are doing intensive hyperparameter tuning, you need to have three separate datasets: the training set, validation set, and test set. When you train the network, you train on the training set, and evaluate the accuracy metric on the validation set. The validation accuracy is then used to tune the hyperparameters. After you find the best hyperparameters, you then evaluate again on the test set to get the true test accuracy. The reasoning for this is because the act of hyperparameter tuning is itself an optimization procedure, and will suffer from overfitting as well. This is best explained in one of Andrew Ng's [video](https://www.youtube.com/watch?v=MyBSkmUeIEs&ab_channel=BlitzKim). A more robust way is to do k-fold cross-validation, which I think is the default method of Tune.
  2. Yes I think your hyperparameter makes sense. Is $\alpha$ the learning rate? You can also try to include batchsize from some set, say $\{2, 4, 8, 16, ...\}$, given your GPU VRAM.
  3. I am not familiar with iRace enough to say it's advantages/disadtanges compared to genetic algorithms. But I know two of the major drawbacks of genetic algorithm is that it doesn't perform well when the number of hyperparameters (or genetic elements) are large, and it has a tedency to converge to local minima.
  
  
  ---
  
  