# Research on the Face Forgery Detection Model Based on Adversarial Training and Disentanglement
## 3 Method
### Adversarial Training  
To effectively utilize synthesized data samples and enhance the feature disentanglement process, we adopt an adversarial training strategy. This method consists of two opposing network components: the generator network (G) and the main discriminator network (D).  
The generator network G aims to generate complex samples, challenging the discriminator D's ability to classify accurately. This process not only challenges the discriminator D's classification skills but also promotes feature independence by complicating the task for the distribution classifier \(\mathrm{C}_{\mathrm{d}}\), thereby improving the disentanglement effect.  
The discriminator D, on the other hand, is designed to minimize the core loss functions essential for precise classification of forged images, forgery types, forgery areas, and feature distributions. This includes addressing the forgery classification loss \(\mathcal{L}_{\text{C}_{\text{ls}}}\), forgery type classification loss \(\mathcal{L}_{\text{C}_{\text{tl}}}\) as outlined in Section 3.2, along with loss \(\mathcal{L}_{R}\) detailed in Section 3.1 to further refine our model's capabilities. Meanwhile, the generator network G heightens the classification challenges for the discriminator D by maximizing the adversarial loss function. Specifically, we apply adversarial loss \(\mathcal{L}_{\text{adv}}\) to all classifiers: \(\text{C}_{\text{ls}}\), \(\text{C}_{\text{t}}\), and forgery areas classifiers, complicating these classifiers to make correct predictions when dealing with forgery features \(\text{f}_{1}\) and forgery type features \(\text{f}_{2}\). This optimization process unfolds as follows:  
\[\min_{\text{D}}\max_{\text{G}}\mathcal{L}_{\text{adv}}(\theta_{\text{(G)}}, \text{w}_{\text{(D)}})=\mathcal{L}_{\text{C}_{\text{ls}}}+\lambda_{1}\mathcal{ L}_{\text{C}_{\text{t}}}+\lambda_{2}\mathcal{L}_{\text{R}} \tag{5}\]  
where \(\theta_{\text{(G)}}\) represents the parameters of the generator G, and \(\text{w}_{\text{(D)}}\) represents the parameters of the discriminator D. \(\lambda_{1}\), \(\lambda_{2}\), represent the hyperparameters of each classification task.  
In order to further enhance the effect and independence of disentangled features, we specifically design the loss of the adversarial distribution classifier. For the distribution classifier \(\text{C}_{\text{d}}\), we treat its classification task as a binary classification task, aiming to reduce the dependency between features by diminishing the mutual information between features \(\text{f}_{1}\) and \(\text{f}_{2}\). During the adversarial phase, we impede the distribution classifier \(\text{C}_{\text{d}}\)'s ability to accurately discern the differences between feature distributions by maximizing the cross-entropy loss. This strategy complicates the task for the distribution classifier \(\text{C}_{\text{d}}\), making it difficult to distinguish accurately between feature distributions. Consequently, this approach strengthens the disentanglement of features and boosts their independence:  
\[\mathcal{L}_{\text{adv-mi}}=-\sum_{\text{i=1}}^{2}\frac{1}{2}\log\frac{\text {e}^{\text{C}_{\text{d}}(\text{f}_{1}\text{f}_{2},\text{ea})_{i}}}{\sum_{ \text{j=1}}^{2}\text{e}^{\text{C}_{\text{d}}(\text{f}_{1}\text{f}_{2},\text{ea })_{j}}} \tag{6}\]  
In Equation (6), we assume equal contribution from each distribution to the loss, to ensure that during the adversarial training process, classifiers are encouraged to output probabilities near a uniform distribution.