# Deep Learning-Based Detection Technology for SQL Injection Research and Implementation
## 5 Experiment and Result Analysis
### Experimental Results and Analysis
#### 5.4.1 Comparative Analysis of Important Hyperparameter Adjustment  
Since the effectiveness of the sample expansion method has been verified and the trained classifier has the best detection effect when the ratio of positive and negative samples in the training data set is 1:1, the hyperparameter adjustments are all tested on the data set DS. The hyperparameters mainly adjusted in the experiment include the optimization algorithm, batch_size, K-value in k-max pooling, etc. Since the positive and negative sample ratios in the dataset DS are balanced, the accuracy of the evaluation index can be selected when adjusting the hyperparameters. (1) Optimization algorithm The optimization algorithm is to accelerate the convergence of the model during the model training process, and it is an algorithm to find the minimum loss function of the model. Using the correct optimization algorithm, it is possible to quickly and efficiently train the model and find the best parameter values. For the training of deep neural networks, the commonly used first-order optimization algorithms include the gradient descent method, momentum method, AdaGrad, RMSProp, and Adam algorithm. The gradient descent method is an iterative algorithm. Usually, the appropriate initial parameters are selected first, and an estimated output, \(y_{i}\), is generated for each input in the training set. The estimated output is then compared with the actual output, \(y_{i}\), and the average error is obtained after all errors are averaged. The value of the parameter is updated in the direction of the negative gradient, and the objective function is minimized iteratively until convergence. It mainly includes three types: SGD, BGD, and MBGD. SGD only randomly samples one sample at each step to estimate the current gradient. It has fast calculation speeds and takes up little memory. However, due to the limited information used in each step, the estimated gradient will be inaccurate, making the convergence of the objective function unstable and accompanied by violent fluctuations. When BGD updates parameters, it will traverse all the data, resulting in slow parameter updates when the amount of data is large. MBGD combines the advantages of SGD and BGD and only uses a fixed number of samples each time the parameters are updated. Generally, the value is a power of two. This can make full use of matrix operations, reduce the number of parameter updates, and achieve more stable results. Generally, this method is often used in deep learning to calculate the gradient and error according to Formulas (8) and (9) and update the parameters according to Formula (10). Where \([x_{1},x_{2},\ldots,x_{m}]\) represents a batch of samples randomly drawn from the training set, the number of samples is \(m\), \(\epsilon\) represents the learning rate, and \(\theta\) represents the initial parameters. \[g\leftarrow+\frac{1}{m}\
abla_{\theta}\sum_{i}L(f(x_{i};\theta),y_{i}) \tag{8}\]  
\[\theta\leftarrow\theta-\epsilon g \tag{9}\]  
The momentum method (Momentum) uses the concept of momentum in physics to use a new variable \(v\) to represent the accumulation of the gradients of the previous few times. It has a certain attenuation in each round and is calculated based on the moving exponentially weighted average of the gradient. The momentum method can better alleviate the problem of large shocks caused by excessive learning rates in MBGD, especially in the case of small gradients, continuous noises, and large noises, and can speed up learning. The gradient and error are calculated according to Formulas (10)-(12), subsequently facilitating the update of the velocity \(v\) and parameter \(\theta\). Among them, \(\epsilon\) represents the learning rate, \(\theta\) represents the initial parameter, \(v\) is the initial velocity, and \(\alpha\) is the momentum decay parameter, which represents the degree of decay of the velocity \(v\) in each round.