## 2 Network Models
### Generative Adversarial Network Model
If a fault motor sample is provided as an input to the fault motor sample generator \(G\), the sample itself should be output. Similarly, when a healthy motor sample is provided as an input to the healthy motor sample generator \(F\), it should yield itself as an output. The loss function is as follows:  
\[Loss_{identity}=\mathbb{E}_{y\in Y}[\left\|G(y)-y\right\|_{1}]+\mathbb{E}_{x \in X}[\left\|F(x)-x\right\|_{1}] \tag{10}\]  
The above problems can be well solved by reducing \(Loss_{identity}\) as much as possible so that the generators \(G\) and \(F\) can have a more vital discrimination ability to the features of the motor samples. Therefore, it can effectively retain the data features to achieve the goal of adding fault features to the healthy motor samples. The three loss functions of Equations (7), (9) and (10) together constitute the Cycle GAN generator loss function, and the generator is trained by continuously reducing the loss function. \[Loss_{Generator}=Loss_{GAN}+Loss_{Cycle}+Loss_{Identity} \tag{11}\]  
For the discriminator, when a motor sample is provided as input to the discriminator, the discriminator will score it to determine whether it is a manual sample or an actual sample. We call the PMSM three-phase stator current data collected by the experimental platform actual samples and the PMSM three-phase stator current data generated by the generator artificial samples. The highest score of the discriminator is 1, and the lowest score is 0. The higher the score, the higher the probability that the discriminator thinks it is an actual sample. Before training the discriminator, we will label the artificial and actual samples as 0 and 1, respectively. When training the discriminator, the mean square deviation between the score of the discriminator on the input sample and the label of the input sample is used as the loss function as follows:  
\[Loss=\mathbb{E}[D(x)-x_{label}]^{2} \tag{12}\]  
The network contains two discriminators, \(D_{X}\) and \(D_{Y}\), which are used to judge the authenticity of the healthy and faulty motor samples. The respective loss functions are as follows:  
\[\left\{ \begin{array}{l}Loss_{D_{Y}}=Loss_{Real}+Loss_{Fake}=\mathbb{E}_{y\in Y }[D_{Y}(y)-1]^{2}+\mathbb{E}_{y^{\prime}\in Y^{\prime}}[D_{Y}(y^{\prime})-0]^{ 2}\\ Loss_{D_{X}}=Loss_{Real}+Loss_{Fake}=\mathbb{E}_{x\in X}[D_{X}(x)-1]^{2}+ \mathbb{E}_{x^{\prime}\in X^{\prime}}[D_{X}(x^{\prime})-0]^{2}\end{array} \right. \tag{13}\]  
where \(X\) is the actual healthy motor sample set and \(Y\) is the actual fault motor sample set. \(X^{\prime}\) is the artificial health point and sample set, and \(Y^{\prime}\) is the artificial fault motor sample set. Take the discriminator \(D_{X}\) as an example: The loss functions of the two discriminators together constitute the overall discriminator loss function of Cycle GAN, as follows:  
\[Loss_{Discriminator}=Loss_{D_{X}}+Loss_{D_{Y}} \tag{14}\]  
The discrimination ability of the discriminator is improved by continuously reducing the \(Loss_{Discriminator}\). It is worth noticing that, as mentioned above, the completion of the training of the network is marked by reaching \"Nash equilibrium\"; that is, the probability of correct judgment by the discriminator is close to 50%, so the ideal balance of the \(Loss_{Disciminator}\) is 0.25. For the convenience of calculation, multiply it by 2, and finally, make it balance at 0.5.