# A Joint Channel Estimation and Compression Method Based on GAN in 6G Communication Systems
## 3 A GAN Based Channel Estimation Scheme
### Model Training Stage: Training A GAN Model to Capture the Distribution of Real Channel
#### 3.1.2 Training Procedure of a GAN Model  
The specific procedure of training a GAN model that generates synthetic channel samples is depicted in Figure 4. As shown in this figure, the training of the generator and discriminator are conducted iteratively. The training procedure can be divided into two cases based on the types of data samples fed into the discriminator. In particular, when real channel data samples are inputted, only the parameters of discriminator need to be updated. The discriminator tries to maximize the output probability \(p_{s}(x)\) so that every real sample can be identified well, and its training objective can be expressed as  
\[\max_{\theta_{d}}\mathcal{O}_{d,r}=\mathbb{E}_{x\sim p_{r}}\{\log D(x;\theta_ {d})\}. \tag{7}\]  
Moreover, when synthetic channel data samples generated by the generator are fed into the discriminator, both the parameters of the generator and discriminator are ready to be updated. Specifically, in terms of the discriminator, its training objective is to minimize the output probability \(p_{s}(x)\) so that the synthetic samples can be distinguished, which is written as  
\[\min_{\theta_{d}}\mathcal{O}_{d,s}=\mathbb{E}_{z\sim p_{z}}\{\log D(G(z;\theta _{g});\theta_{d})\}. \tag{8}\]  
As for the generator, its training objective is to maximize the output probability \(p_{s}(G(z;\theta_{g}))\) so that the produced synthetic samples can deceive the discriminator to regard themselves as real samples, which is expressed as  
\[\max_{\theta_{g}}\mathcal{O}_{g}=\mathbb{E}_{z\sim p_{z}}\{\log D(G(z;\theta_ {g});\theta_{d})\}. \tag{9}\]  
Figure 3: The structure of GAN.  
Based on the training objectives \(\mathcal{O}_{d,r}\) in (7), \(\mathcal{O}_{d,s}\) in (8) and \(\mathcal{O}_{g}\) in (9), the procedure of training a GAN model to generate synthetic channel samples is summarized in Algorithm 1. In Algorithm 1, the generator is trained once when the parameters of the discriminator have finished \(R\) times updates, which is of benefit for balancing the performance between the generator and discriminator during the training procedure and avoiding the mode collapse issue [27]. The parameters can be updated via using gradient descent methods. In addition, the widely used cross entropy function is usually selected as the loss function for training the GAN model. After the GAN model is converged, stable synthetic channel samples can be generated.  
```
0:\(\theta_{d}(0)\), \(\theta_{g}(0)\), the maximum number of iterations \(K\), the ratio of training rounds between the discriminator and generator \(r\), batch size \(N_{B}\), learning rate \(\lambda\), the form of loss function \(F_{T}(\cdot)\), and the convergence threshold \(\delta\). Repeat: For \(k\)-th iterations, \(1\leq k\leq K\)
1. Sample \(N_{B}\) real channel samples;
2. Generate \(N_{B}\) synthetic channel samples by feeding \(N_{B}\) sampled latent variables \(z\) independently into the generator;
3. Feed real samples and synthetic samples into the discriminator, then calculate the loss function with respect to real samples as \(L_{d,r}=F_{T}(\mathcal{O}_{d,r})\), and calculate the loss function with respect to synthetic samples as \(L_{d,s}=F_{T}(\mathcal{O}_{d,s})\);
4. Update \(\theta_{d}(k)\) by following \(\theta_{d}(k)=\theta_{d}(k-1)+\frac{1}{N_{B}}\sum_{n=1}^{N_{B}}\lambda\
abla_ {\theta_{d}}(L_{d,r}-L_{d,s})\); If\(k\) mod \(r=0\), do generator training:
5. Generate another \(N_{B}\) synthetic channel samples and feed into discriminator;
6. Calculate the loss function \(L_{g}=F_{T}(\mathcal{O}_{g})\);
7. Update \(\theta_{g}\) by following \(\theta_{g}(\lfloor k/r\rfloor)=\theta_{g}(\lfloor k/r\rfloor-1)-\lambda\
abla _{\theta_{g}}L_{g}\).

**Termination:** When \(k>K\) or \(\|\theta_{d}(k)-\theta_{d}(k-1)\|\leq\delta\) and \(\|\theta_{g}(\lfloor k/r\rfloor)-\theta_{g}(\lfloor k/r\rfloor-1)\|\leq\delta\). Output: Trained discriminator with parameters \(\theta_{d}^{*}\) and generator with parameters \(\theta_{g}^{*}\).
```  
**Algorithm 1** GAN-based synthetic channel samples generation.