## 10 Machine Learning Basics: Unlocking AI's Core Principles
### Exploring CNN-Based Approaches: Cutting-Edge Techniques  
A CNN processes the input \(x(i)\) through several layers [129; 130; 131].  
1. Convolutional Layers Each convolutional layer transforms the input through a set of convolutional filters, \(\{F_{k}\}\), where each filter has parameters \(w_{k}\) and applies a convolution followed by a nonlinear activation (e.g., ReLU,\(\sigma\)). The output of each filter, for a given layer, is given by \[C_{k}^{(i)}=\sigma(w_{k}*x^{(i)}+b_{k})\] (26) where \(C_{k}^{(i)}\) is the convolutional output, \(b_{k}\) is the bias, and \(\sigma\) is the nonlinear activation function.
2. Pooling Layers They reduce the dimensionality of the output of convolutional layers by applying operations such as max pooling, which selects the maximum value in specific sub-regions of the input: \[P^{(i)}=\max_{\text{subregion}}C_{k}^{(i)}.\] (27)
3. Fully Connected Layers The last layers of the network are fully connected and map the extracted features to the final outputs representing the model's predictions: \[F^{(i)}=\sigma(W\cdot P^{(i)}+b),\] (28) where \(W\) and \(b\) are the respective weights and biases.  
The objective function to be minimized, often chosen as the cross-entropy between the predicted and true labels to classify whether the signal segment contains artifacts, can be formulated as  
\[J(W,b)=-\frac{1}{N}\sum_{i=1}^{N}\Big{[}y^{(i)}\log(F^{(i)})+(1-y^{(i)})\log(1- F^{(i)})\Big{]}. \tag{29}\]  
The training of the network is carried out by optimizing the parameters \(W\) and \(b\) by minimizing \(J\). The updating of the parameters typically occurs via gradient descent or its variants such as Adam, calculating the gradients of the objective function regarding the parameters:  
\[W_{\text{new}}=W_{\text{old}}-\alpha\
abla_{W}J(W,b), \tag{30}\]  
\[b\text{new}=b_{\text{old}}-\alpha\
abla_{b}J(W,b), \tag{31}\]  
where \(\alpha\) is the learning rate [129; 130; 131].  
After training, a neural network is capable of classifying new EEG signal segments by detecting the presence of artifacts. Based on the model's predictions, segments believed to contain artifacts can be modified or eliminated. Some advanced models can also generate a \"clean\" EEG signal as output, introducing methods of removing artifacts through signal reconstruction. Specifically, Convolutional Neural Networks (CNNs) can analyze previously unseen segments of an EEG, assigning each a probability of containing artifacts, using sigmoid or softmax functions to transform the network's output into those probabilities:  
\[\hat{y}^{(i)}=\sigma(F^{(i)})=\frac{1}{1+e^{F^{(i)}}} \tag{32}\]  
where \(\sigma(\cdot)\) denotes the sigmoid function and \(F^{(i)}\) is the output of the last fully connected layer of the CNN for the \(i\)-th segment.  
Based on \(\hat{y}^{(i)}\), a decision is made on how to treat each segment of the EEG signal. Typically, a threshold, \(\tau\) (e.g., \(\tau\) = 0.5), is established to classify a segment as containing an artifact if \(\hat{y}^{(i)}>\tau\). Segments identified as artifacts can be removed, interpolated, or treated with specific artifact removal techniques.  
If a segment is classified as containing artifacts, there are several mathematically sound strategies for its removal or treatment.