## 2 Materials and Methods
### Neural Network Architecture  
Once the _dataset_, the 12,000 \((p,q)\)-planes or representative patterns of the 40 subjects, is available, the repository is organized into two subsets of data: one for training (training + validation) and one for testing for the creation and evaluation of the model to be developed, as is usual in ML. On the first subset, the data for _training_ is reserved for applying the DL algorithm and, thus, can obtain the model's parameters. The data for _validation_ is used to readjust the hyperparameters prior to each iteration of the training phase and to evaluate our model in each epoch, saving the best of them, which in our case uses a _batch size_ of 30 patterns chosen at random if the performance finally achieved is to be achieved. The model is trained using the training set and evaluated once each _epoch_ using the validation set. We define our training schedule to stop the training after a predefined number of _epochs_ without improvement in validation set loss and accuracy. This can result in a final classification that falsely favors the selected validation subset and prevents the model from correctly generalizing. To accurately assess how well the model performs, it is necessary to use a separate set of data called \"testing\", not included in the training phase. Although various validation techniques organize the data in multiple ways [46], in our case, 60% of the data is assigned to the training phase, 20% to the validation phase and 20% to the test phase, according to a balancing of the data; that is, in each of the phases the same number of patterns is available in the basal and stressed state, as well as the same number of patterns for each subject. A model test design was carried out using the adapted CRISP-DM methodology. This task consisted of generating and evaluating successive models with different convolutional layers (from 2 to 4) and other numbers and sizes of initial filters, allowing us to converge on the final model with the best performance presented. The general architecture of the CNN model is illustrated in Figure 3. Since the problem of identifying a stressed state is not simple, the following successive layers are contemplated:  
* Four stages of **2D convolutional layer** (Conv2D) + **Max Pooling 2D layer**. Convolutional layers are applied to feature maps (_feature maps_) that are fed from RGB images of dimensions \(224\times 168\) with a depth of 1 (channels). The image format is irrelevant in geometric analysis, as in our case. In the first two stages, the convolutional layers contain a particularly large _kernel_, of dimension \(13\times 13\) (the filter consists of the _kernel_ and a bias) and a _pooling_ of \(2\times 2\) (the sliding window that scrolls through the convolutional layer to output the maximum number of values from the four input window pixels). In the last two stages, the convolutional layers, with dimensions \(9\times 9\) and the _pooling_ layers, with a _pooling_ window of dimension \(2\times 2\). The _kernels_ of dimensions \(13\times 13\) facilitate the identification of those more global patterns or characteristics present in the input images while the _kernels_ of the innermost layers, with dimensions \(9\times 9\), allow more local patterns to be captured. * **Flatten Layer**: a layer that transforms the input image matrix into a one-dimensional array. * **Dense Layer**: _fully connected_ hidden layer of 12 neurons with ReLU activation function. The Rectified Linear Unit (ReLU) function defined as \(f(x)=x\) if \(x\leqslant 0\) and \(f(x)=0\) if \(x<0\), applied to the feature maps, provides the non-linearity required to carry out the task detection of stress patterns [47]. Furthermore, it has been chosen for its low computational cost to achieve good stochastic gradient descent convergence performance. It allows the network-learning process to be faster without penalizing generalization, avoiding the vanishing gradient problem that other activation functions tend to (sigmoid, tangh and others).