## 3 FDIA Detection Model Based on GAN-GRU and Transformer
### GAN-GRU-Based Data-Balancing Process  
#### 3.1.1 Network Structure of GAN-GRU  
Our data-balancing processing model utilizes generators and discriminators of generative adversarial network discriminators to balance the entire dataset by generating synthetic samples with the class balance to increase the number of samples in a few classes. At the same time, we employ generators and discriminators with gated loop units to capture temporal dependencies in the sequential data to ensure that the generated samples are temporally consistent. In this way, we are able to effectively deal with the imbalance problem in the historical measurement data, thus improving the performance of the fault-checking model. In order to deal with a small number of attack vectors in the training dataset, they are preprocessed and used as inputs to the GAN, which are trained through continuous iterations of the generator and discriminator, with the ultimate goal of generating a balanced dataset. The gated recurrent unit initially introduced in [25] and referenced as a structure of a gated recurrent unit represents an evolved iteration of the conventional recurrent neural network. Its effectiveness lies in efficiently capturing semantic correlations within extended sequences, thus addressing the challenge of gradient vanishing or explosion. In parallel, similar to the long short-term memory unit, GRU also incorporates gating units to regulate information flow. Nevertheless, GRU differs from LSTM in that it lacks an independent storage unit, exhibiting a more streamlined structure and computational process. Its operation involves a reset gate and an update gate, forming a core structure that can be expressed as follows:  
\[\mathbf{z_{t}}=\sigma\Big{(}\mathbf{W}^{(z)}\mathbf{x_{t}}+\mathbf{U}^{(z)}\mathbf{h_{t-1}}\Big{)}, \tag{8}\]  
\[\mathbf{r_{t}}=\sigma\Big{(}\mathbf{W}^{(r)}\mathbf{x_{t}}+\mathbf{U}^{(r)}\mathbf{h_{t-1}}\Big{)}, \tag{9}\]  
\[\widetilde{\mathbf{h}}_{t}=\tanh(\mathbf{U}\mathbf{r_{t}}\circ\mathbf{h_{t-1}}+\mathbf{W}\mathbf{h_{t- 1}}), \tag{10}\]  
\[\mathbf{h}_{t}=(1-\mathbf{z_{t}})\circ\mathbf{h_{t-1}}+\mathbf{z_{t}}\circ\widetilde{\mathbf{h}}_{ t}, \tag{11}\]  
where \(\mathbf{x_{t}}\) is the input information at the current moment; the variants denoted as update gate \(\mathbf{z_{t}}\) and reset gate \(\mathbf{r_{t}}\) function as intermediary entities within this framework; \(\sigma\) is the sigmoid activation function; the summation of both the input and the past hidden layer state is denoted by \(\widetilde{\mathbf{h}}_{t}\) with \(\mathbf{h}_{t-1}\) signifying the latter; \(\mathbf{W}^{(z)}\), \(\mathbf{U}^{(z)}\), \(\mathbf{W}^{(r)}\), \(\mathbf{U}^{(r)}\), \(\mathbf{U}\), and \(\mathbf{W}\) are the trainable parameter matrices; and \(\circ\) is the Hadamard product and tanh is the tanh activation function. The utilization of GRU as both the generator and discriminator within the context of a GAN for balanced datasets provides a multitude of benefits and advantages. Firstly, in its role as a generator, the inherent ability of GRU for recursive modeling facilitates the generation of high-quality and diverse synthetic samples, thereby effectively augmenting the number of samples within specific categories. Acting as a discriminator, GRU's proficiency in classification and discrimination lends accuracy to the assessment of generated sample quality, thus enhancing the effectiveness of balanced datasets. This process is further optimized through appropriate training and fine-tuning, enabling GRU to strike a harmonious equilibrium between its roles as generator and discriminator. This equilibrium significantly contributes to further improving the dataset balance and ultimately enhances the performance of the fault detection model. The strategic integration of GRUs as generators and discriminators within GANs presents a robust solution for data-balancing processing, thereby offering substantial improvements in data processing efficacy and quality within practical applications.