# Malware Variants Detection Model Based on MFF-HDBA
## 3 Methodology
### Hyperparameter Optimization Based on Discrete Bat Algorithm  
Setting hyperparameters can directly affect the performance of the model. Consequently, the selection and setting of hyperparameters is a difficult and hot topic for research in deep learning models. There are many important hyperparameters in CNN, such as the number of network layers, the number of neurons per layer, and the learning rate. The more layers there are of the neural network and the number of neurons per layer, the more that the feature extraction capability of the network can be enhanced, and the more this facilitates solving complex problems. However, when the number of neural network layers and the number of neurons per layer become too numerous, it leads to the CNN model, resulting in weakened generalization ability. The learning rate is an important hyperparameter that affects convergence of the model. If the learning rate is too large, the faster the parameters are updated in back propagation, and the loss function becomes prone to oscillation, making convergence difficult. If the learning rate is too small, the parameter update in back propagation becomes slower. In addition, it makes the loss function converge slowly, causing overfitting. At present, there is no theorem for the hyperparameter settings, or a generally applicable consensus setting method. In practice, the hyperparameter settings rely on human experience, resulting in continuous adjustments from referring to settings in some typical models or training effects of the model. The hyperparameter adjustment method that relies on human experience lacks theoretical basis and interpretability. In addition, the method can only adjust each hyperparameter one by one, and it is difficult to take into account different hyperparameters. If multiple hyperparameters are adjusted at the same time, it is difficult to determine exactly which hyperparameter adjustment is affecting the performance of the model. Furthermore, sometimes a single adjustment of the hyperparameters may be difficult to improve the performance of model, leading it to become trapped in a local optimum. The swarm intelligence algorithm is an effective measure to solve complex optimization problems. In order to solve the issue of hyperparameter optimization, this paper proposed a hyperparameter optimization algorithm based on the discrete bat algorithm, referred to as HDBA. The bat algorithm is a swarm intelligence algorithm inspired by the behavior of bats, which use echoes to detect prey and avoid obstacles. The standard bat algorithm is adapted to solve the optimization problem for continuous values, while the hyperparameters are discrete values. Therefore, we discretize the population's position and velocity updates to overcome the limitations of the standard bat algorithm. We utilize the accuracy of the model as the objective function, and the position of the bat is the set of the number of multi-scale feature extraction blocks and the number of convolutional kernels in each convolution. The optimization search process ends when the epoch reaches the max iteration. The process of parameter optimization is shown in Algorithm 1. ```
Input:\(X\): bat population; Output:\(HParam_{best}\): the best Hyperparameter setting;
1 Initialize original bats population \(X\), velocity \(v\);
2\(x_{best}\leftarrow\) GetBest\((Accuracy)\)
4 While\(t<maxIterations\)do
5 for\(x_{i}\subset X\)do
6\(\left(x_{i}^{t+1},v_{i}^{t+1}\right)\leftarrow\) update\(\left(x_{i^{\prime}}^{t},v_{i}^{t}\right)\)
7\(\left(x_{i}^{t+1},v_{i}^{t+1}\right)\leftarrow\left(\left[x_{i}^{t+1}\right], \left[v_{i}^{t+1}\right]\right)\)
8\(Accuracy_{i}^{t+1}\leftarrow\)\(f\left(x_{i}^{t+1}\right)\)
9
10\(X\leftarrow\) LocalSearch\((X)\)
11\(x_{best}\leftarrow\) GetBest\((X)\)
12\(t=t+1\)
13\(HParam_{best}\gets x_{best}\)
14
15 end
```  
**Algorithm 1**HDBA operation  
In the algorithm, _GetBest_ is the global optimization function for the bat population, and _LocalSearch_ is a local search of bat populations.