# An Improved GAN-Based Image Restoration Method for Imaging Logging Images
## 2 Preparatory Knowledge  
### Generating Adversarial Networks  
A generative adversarial network (GAN) automatically captures the data distribution of a real sample set, i.e., it grasps the mapping pattern between the input and output images. The two train the model according to the rules of the minimal-maximal binary game. The training process can be represented by the objective function formula:  
\[\max_{D}\min_{G}V(D,G)=E_{x\sim f_{d}(x)}\log D(x)+E_{y\sim f_{y}(y)}\log(1-D(G( y))) \tag{1}\]  
where \(G\) and \(D\) denote the generator and discriminator, respectively. \(f_{d}(x)\) denotes the distribution of real data, \(f_{y}(y)\) denotes the distribution of data generated by the generator, \(D(x)\) denotes the probability that \(x\) is real data and not data generated by the generator, and \(D(G(y))\) denotes the probability value when the samples generated by the generator are used as input to the discriminator. From the objective function, it can be seen that the optimisation objective in training the discriminator is to maximise \(D(x)\) close to 1 and minimise \(D(G(y))\) close to 0. The optimisation objective in training the generator is to maximise \(D(G(y))\) close to 1. This means that the two networks play off each other to optimise their own performance so that the discriminator cannot tell whether the output image of the generator is true or false.  
Through the in-depth study of GAN ideas and the reproduction of the original GAN model, it is elaborated according to its own understanding of the overall process of the GAN model algorithm, as shown in Algorithm 1.  
```
1:In each training iteration: initialise the generator parameter to \(\theta_{g}\) and the discriminator parameter to \(\theta_{d}\).
2:for 1 steps do: study D.
3: sampling m sample images from the dataset, i.e., \(x^{1},x^{2},\ldots,x^{m}\) m = batch size.
4: sampling m vectors from some distribution (e.g., orthogonal, Gaussian), i.e., \(z^{1},z^{2},\ldots,z^{m}\).
5: get the generated data \(\tilde{x}^{1},\tilde{x}^{2},\ldots,\tilde{x}^{m},\tilde{x}^{i}=G\left(z^{i}\right)\).
6: update the discriminator parameter \(\theta_{d}\) to maximum.
7:\(\tilde{V}=\frac{1}{m}\sum_{i=1}^{m}\left(\log D(x^{i})+\log(1-D(\tilde{x}^{i} ))\right)\)
8:\(\theta_{d}\leftarrow\theta_{d}+\eta\
abla\tilde{V}(\theta_{d})\)
9: end.
10:for 2 steps do: study G.
11: sampling m vectors from some distribution (e.g., normal, Gaussian), i.e., \(z^{1},z^{2},\ldots,z^{m}\).
12: update the parameter \(\theta_{g}\) of the generator to maximize.
13:\(\tilde{V}=\frac{1}{m}\sum_{i=1}^{m}\log(D(G(z^{i})))\)
14:\(\theta_{g}\leftarrow\theta_{g}-\eta\
abla\tilde{V}(\theta_{g})\)
15:end.
```  
**Algorithm 1** original GAN model algorithm flow  
The basic structure of GAN can be better understood with the help of the above algorithmic flow, as shown in Figure 1. The input is a random noise variable \(y\)-\(f_{y}(y)\) that conforms to a uniform distribution or other random distribution. The generator G outputs by capturing the true data distribution \(x\)-\(f_{d}(x)\) and disguising the received noise variable as a true sample data distribution G(\(y\)). The discriminator receives the true data and the generated data and outputs a probability value; this value ranges from 0 to 1, with 0 indicating that the current image is a false sample and 1 indicating that the current image is a real sample, as a way to determine the probability that the received data is real data [10].  
During the training process of the GAN model, the generator G aims to generate data sufficient to deceive the discriminator D, while D aims to accurately distinguish between the data generated by G and the real data. The two play off each other to achieve their respective goals, and eventually converge to Nash equilibrium in their co-evolution [11] when the generator G is able to generate data close to the real data.