## 2 Materials and Methods
### Gan  
GANs have emerged as a transformative framework in the field of generative modeling since their introduction by [PERSON] et al. in 2014, as they are designed for unsupervised learning and provide a mechanism to learn the underlying data distribution without the need for labeled samples [40]. This capability is particularly relevant in the context of intrusion detection in edge and IIoT systems, where data are often high-dimensional, heterogeneous, and heavily imbalanced. The GAN architecture is composed of two neural networks (the generator and the discriminator) that are trained simultaneously through an adversarial process. The generator \(G\) is responsible for synthesizing fake data samples from a latent noise distribution, while the discriminator \(D\) attempts to distinguish between real and synthetic inputs. The interaction between these two networks forms a two-player minimax game in which each network iteratively improves its performance in opposition to the other. Initially, the generator produces low-quality samples that the discriminator can easily classify as fake. However, as training progresses, the generator learns to model the data distribution more effectively, eventually producing outputs that are increasingly difficult for the discriminator to distinguish from real data. This dynamic leads to a powerful generative process that can synthesize realistic data samples, making GANs particularly useful for augmenting rare classes and learning complex decision boundaries [41]. The standard structure of a GAN is illustrated in Figure 1, which shows the interaction between the dataset, the generator \(G\), and the discriminator \(D\). The generator takes a noise vector sampled from a prior distribution and outputs synthetic data samples. These synthetic samples, alongside real data drawn from the dataset, are fed into the discriminator, which performs a binary classification to determine whether the input is real or fake. The discriminator then provides feedback to the generator in the form of gradients, which guide the generator in learning to produce increasingly realistic samples. This adversarial training process is repeated iteratively until the generator is capable of producing samples that are indistinguishable from real data [42]. The objective of GAN training is captured by a value function that defines the minimax game between the generator and the discriminator. This is expressed formally in Equation (1), where the discriminator aims to maximize its ability to classify real samples as real and fake samples as fake, while the generator attempts to minimize the discriminator's ability to distinguish real from synthetic data [40]:  
\[ \begin{array}{c}min\ max\\ G\quad D\end{array} V(D,\ G)=\mathbb{E}_{X\sim p_{data}(X)}\left[log\left(D(X) \right)\right]+\mathbb{E}_{Z\sim p_{Z}(z)}\left[log\left(1-D(G(Z))\right)\right], \tag{1}\]  
where \(p_{data}(x)\) represents the distribution of real data; \(p_{Z}(z)\) denotes the prior distribution over the latent noise vectors; \(D(X)\) refers to the probability output of the discriminator for a real input \(X\), while \(D(G(Z))\) denotes the probability assigned to a sample synthesized by the generator. The generator and discriminator are updated alternately using stochastic gradient descent to minimize and maximize this value function, respectively. The training process for each network can be further decomposed into their individual loss functions. The loss function for the discriminator, shown in Equation (2), is designed to increase the likelihood of correctly classifying real and fake samples. It is the negative log-likelihood of assigning the correct label to both real and generated data:  
\[L_{D}=-\Big{(}\mathbb{E}_{X\sim p_{data}(x)}\left[log\left(D(X)\right)\right]+ \mathbb{E}_{Z\sim p_{Z}(z)}\left[log\left(1-D(G(Z))\right)\right]\Big{)}, \tag{2}\]  
where \(L_{D}\) is the loss functions for the discriminator. Conversely, the generator's objective is to deceive the discriminator by generating samples that are classified as real.