# Machine Learning-Based Methods for Enhancement of UAV-NOMA and D2D Cooperative Networks
## 4 ANN-Based Placement Scheme Selection
### ANN Model Construction  
ANN has the most hyper-parameters to be tuned among all the ML algorithms. Consequently, this subsection provides a concise but adequate description of the standard hyperparameters of an ANN model and their tuning. The first step in hyperparameter tuning is finding the layer type [39]. Since non-linear data collection is used in this study, we investigate a fully connected multi-layer perceptron (MLP) network in which the input from the dataset propagates in one direction through one or more hidden layers. Therefore, using the normalized feature vectors obtained through (31) and their corresponding labels, we can build an ANN model consisting of one input layer, \(l_{i}=1\), \(l_{h}\in\{1,2,...,L\}\) hidden layers, and one output layer \(l_{o}=1\) for the PSS prediction. The \(l_{i}\) layer consists of \(m_{i}=8\) neurons which represent the input features vector \(\mathbf{x_{i}}\) for the ANN:  
\[\mathbf{x_{i}}=\Big{[}D_{\text{ptc}},D_{\text{ptm}},r_{\text{min}}^{p_{c}},r_{ \text{max}}^{p_{m}},r_{\text{min}}^{p_{m}},r_{\text{max}}^{p_{m}},\text{PL}_{ \text{sum}}^{p_{c}},\text{PL}_{\text{sum}}^{p_{m}}\Big{]}. \tag{32}\]  
Each term mentioned in (32) is a real number and is described in detail in Table 2. Moreover, the \(l_{o}\) consists of \(m_{o}=2\) neurons, which is the total number of classes that we want to predict. The number of neurons \(m_{h}\) per hidden layer can be determined as [40]:  
\[m_{h}=\left[\frac{m_{i}+\sqrt{d}}{l_{h}}\right] \tag{33}\]  
Consequently, if there is one hidden layer (\(l_{h}=1\)), the number of neurons is 63 according to (33). Similarly, the number of neurons for two hidden layers (\(l_{h}=2\)) is 31.5 per layer, resulting in the selection of 32 and 31 neurons for the first and second hidden  
Figure 3: Distribution of data set per class. layers. Additionally, we model ANN with \(l_{h}=3\) and \(l_{h}=4\) hidden layers, and the number of neurons per each hidden layer is listed in Table 3.  
The following step in hyperparameter tuning concerning ANN models is to determine the activation and the loss function. In this study, the rectified linear unit (ReLU) activation function is employed in hidden layers. It is easy to build and overcome the constraints of widely used activation functions like Sigmoid and Tanh. Furthermore, since PSS may be seen as a binary classification problem, the output layer activation function is SoftMax. Regarding the loss function, cross-entropy is utilized since it is the most widely used for classification problems. Therefore, in order to find the best ANN hyperparameters, the selected loss function should be minimized. The minimization of the loss function is achieved through gradient descent (GD) with momentum backpropagation. The momentum term navigates the GD along the relevant direction and softens the oscillations in irrelevant directions. For this purpose, the grid search method is utilized. Accordingly, the momentum is tested for values between 0.2 and 1 with a step of 0.1. In the last phase of hyperparameter tuning, the learning rate and the number of epochs are chosen. The learning rate is evaluated for values between 0.001 and 0.1 with a step of 0.001, while the number of epochs range is set to be from 1 to 1000. In addition, the early stopping criterion is used to improve the model's generalization capability and minimize overfitting. Finally, in Table 4, all the finalized hyperparameters are listed for ANNs methods derived throughout the training, validation, and testing process. Figure 4 presents the evaluation of the training, validation, and testing phases in terms of the loss function versus the number of epochs. In essence, the number of epochs directly affects the adopted method's convergence. The low number of epochs entails that the algorithm may converge at a local minimum. Nonetheless, too many epochs may lead to over-learning.