# WGAN-Based Realization Process of Gravel Soil for Hydraulic Property Simulation
## 3 Model Training  
### Generative Adversarial Nets (GANs)  
[PERSON] et al. (2014)[PERSON] et al. (2014) proposed the framework of the GAN technique to address the generative problem, which aims to train a generative model that can approximate an unknown distribution \(p_{data}\) over a high-dimensional space \(\mathbf{\chi}\) given many observed real samples \(x_{r}\) from this distribution, i.e., \(x_{r}\sim p_{data}\). Figure 2 illustrates the typical workflow of a GAN. A GAN generally consists of two trainable blocks, a generator (\(G_{\theta}\)), and a discriminator (\(D_{\varphi}\)), with \(\theta\) and \(\varphi\) being trainable parameters. A latent variable \(Z\) is defined with a known distribution \(p_{z}\) (e.g., Gaussian) over a low-dimensional space \(\mathbf{Z}\), and \(z\) is considered a sample from \(\mathbf{Z}\), i.e., \(z\sim p_{z}\). The generator \(G_{\theta}\) maps \(z\) into \(x_{G}\), which lies in the space \(\mathbf{\chi}\), i.e., \(x_{G}=G_{\theta}(2)\); the distribution of \(x_{G}\) is \(p_{G}\), i.e., \(x_{G}-p_{G}\). The discriminator \(D_{\varphi}\) maps the generated samples \(x_{G}\) and the given data samples \(x_{r}\) into two scalar values called scores \(s_{G}\) and \(s_{r}\), respectively, i.e., \(s_{G}=D_{\varphi}(x_{G})\), \(s_{r}=D_{\varphi}(x_{r})\). These scores evaluate the similarity of the inputs of \(x_{G}\) and \(x_{r}\). The loss function of GANs is based on some type of distance between \(s_{G}\) and \(s_{r}\) (Equation (1)), which represents the distance between \(p_{G}\) and \(p_{data}\). As shown in Figure 2, the discriminator \(D_{\varphi}\) and the generator \(G_{\theta}\) are alternatively trained by maximizing and minimizing the loss function (Equation (1)) until a certain stopping (Minimax) criterion is reached.  
\[J^{(D)}=-\mathbf{E}_{x_{r}\sim p_{data}}logD_{\varphi}(x_{r})-\mathbf{E}_{x_{G}\sim p _{G}}log\big{(}1-D_{\varphi}(G_{\theta}(z))\big{)} \tag{1}\]  
\[J^{(G)}=\mathbf{E}_{x_{G}\sim p_{G}}log\big{(}1-D_{\varphi}(x_{G})\big{)} \tag{2}\]  
where \(J^{(\cdot)}\) is some type of distance between \(x_{G}\) and \(x_{r}\), such as Jensen-Shannon divergence, and \(\mathbf{E}\) is the expectation over \(x_{G}\sim p_{G}\) and \(x_{r}\sim p_{data}\).  
The generator and discriminator antagonize each other until the generated data fully merge with the real data, making the distributions of the model almost identical to reach a Nash equilibrium, i.e., a saddle point of the discriminator loss. The optimization strategy of the discriminator can be derived as follows.  
\[D_{\varphi}^{*}(x)=\frac{p_{data}(x_{r})}{p_{data}(x_{r})+p_{G}(x_{G})} \tag{3}\]  
Estimating this ratio using supervised learning is the key approximation mechanism used by GANs. As shown in the last picture in Figure 2, when the discriminator (\(D_{\varphi}\)) is unable to effectively distinguish between the real samples \(x_{r}\) and the generated samples \(x_{G}\), it indicates that the generator (\(G_{\theta}\)) has successfully learned the features that are similar to the real data distribution, i.e., \(x_{r}\sim p_{data}\). This means that the generator has acquired the ability to generate realistic samples.  
In summary, the GAN framework can train a generative model that approximates an unknown data distribution by utilizing observed real samples. A GAN consists of a generator and a discriminator, where the generator creates data from a latent variable, and the discriminator evaluates the authenticity of the generated and real samples. The two components are trained in opposition to minimize their respective loss functions until they reach a Nash equilibrium, signifying that the generator can produce realistic samples indistinguishable from the actual data distribution.