# PUE Attack Detection by Using DNN and Entropy in Cooperative Mobile Cognitive Radio Networks
## 3 Deep Neural Network and Entropy to Multiple PUE Detection in Cooperative MCRN
### Deep Learning Techniques for the Decision of PUE Presence
In deep neural networks, three types of layers can be distinguished: the input layer, which has as many neurons as variables present in the training data; the deep hidden layer or layers; and the output layer, as shown in Figure 2[27]. Figure 2: Deep artificial neural network. In this paper, we propose to use a DNN; the input layers are the SNR and entropy of the measured signals, and with this data, each SU can detect the _PUE attack_ using supervised learning and an adequately labeled dataset. This data set is divided into training and test or validation data. The network training stage follows an iterative process that includes several phases:  
Initialization of parameters: Initially, the weights and biases of each neuron in the network are adjusted. These values can be chosen randomly or they can be assigned according to a probability distribution. Forward propagation: In forward propagation of an \(L\)-layer neural network, a \(Z\)-weighted sum of the \(X\) inputs and the b biases of each neuron in the layer is performed, where the weights \(w\) represent the contribution of each input in the layer in the weighted sum, as can be seen in Equation (8). In this case, the inputs are the SNR and the entropy of the averaged energy of the received signal. \[Z^{L}=w^{L}X+b^{L} \tag{8}\]  
Subsequently, a nonlinear activation function \(a\) is applied to the weighted sum \(Z\) to obtain the response \(\hat{y}\), as seen in Equation (9). \[\hat{y}=a(Z^{L}) \tag{9}\]  
_Error_ calculation: The _error_ is obtained by calculating the cost function \(C\), which measures the discrepancy between the predicted output \(\hat{y}\), and the desired output or label \(y\). The cost function \(C\) can be the root mean square _error_ (RMSE) in cases of regression or cross-entropy in classification problems; the _error_ can be seen in Equation (10) [28]. \[Error=y-\hat{y}=C(a(Z^{[L]})) \tag{10}\]  
Backpropagation: After the _error_ calculation, the backpropagation phase begins, in which the weights and biases of each neuron are adjusted to achieve the desired output. The cost function is optimized using algorithms, such as gradient descent, to minimize the _error_. In this way, it seeks to achieve a solution that allows a better network generalization to make accurate predictions on new data, reducing the _error_ in the last layer, as seen in Equation (11) [29]. \[\delta^{L}=\frac{\partial C}{\partial a^{L}}\frac{\partial a^{L}}{\partial z^ {L}} \tag{11}\]  
The backpropagation for the _error_ can be seen in Equation (12). \[\delta^{L-1}=W^{L}\delta^{L}\frac{\partial a^{L-1}}{\partial z^{L-1}} \tag{12}\]  
Then, the derivatives of the biases are calculated in Equation (13). \[\frac{\partial C}{\partial b^{L-1}}=\delta^{L-1} \tag{13}\]  
Finally, the derivatives of the weights are also calculated in Equation (14). \[\frac{\partial C}{\partial w^{L-1}}=\delta^{L-1}a^{L-2} \tag{14}\]  
Optimizing the weights and biases of the neural network based on their derivatives, known as backpropagation, is carried out by the backpropagation of the error from the output layer to the previous layers. This process is repeated with all the training data in one epoch and is executed multiple times until the network can capture the patterns in the data. Then, the validation of the network is carried out using the test data to measure its efficiency. If the performance is unsatisfactory, the hyperparameters are adjusted, and the entire procedure is repeated [29]. After all the DNN processes are achieved (training, testing, and validation), each SU can detect the _PUE attack_ by taking some samples, as will be explained in the next section.