## 2 Network Models
### Generative Adversarial Network Model
After the motor fault sample \(y^{\prime}\) generated by the generator \(G\) is input into the generator \(F\), the generated motor health sample \(x^{\prime\prime}\) should be as consistent as possible with the motor health sample \(x\) initially input into the generator \(G\). Similarly, after the health motor sample \(x^{\prime}\) generated by the generator \(F\) is provided as input to the generator \(G\), the generated fault motor sample \(y^{\prime\prime}\) should be as consistent as possible with the fault motor sample \(y\) initially entered into the generator \(F\), which is  
\[\left\{ \begin{array}{l}F(G(x))\approx x\\ G(F(y))\approx y\end{array} \right. \tag{6}\]  
The overall model is shown in Figure 3.  
When training the network, the samples \(y^{\prime}\) and \(x^{\prime}\) generated by the generators \(G\) and \(F\) will be judged by discriminators \(D_{Y}\) and \(D_{X}\). Then, the discriminators output a score (0-1), representing the possibility that the discriminator can determine that the samples are actual. The higher the score, the higher the possibility that the samples are from the actual sample set. Therefore, the mean deviation between the sample score and the highest score generated by the generator is employed as a loss function to quantify the effectiveness of the generator. By reducing the loss function, the learning ability of the generator, i.e., the ability to \"hide\" the discriminator, is improved. The loss function is as follows:  
\[Loss_{GAN}=L_{GAN}(G,D_{Y},Y)+L_{GAN}(F,D_{X},X) \tag{7}\]  
\[\left\{ \begin{array}{l}L_{GAN}(G,D_{Y},X)=\mathbb{E}_{x\in X}\big{[}D_{Y}(G (x))-1\big{]}^{2}\\ L_{GAN}(F,D_{X},Y)=\mathbb{E}_{y\in Y}\big{[}D_{X}(F(y))-1\big{]}^{2}\end{array} \right. \tag{8}\]  
where \(X\) and \(Y\) are the healthy sample set and fault sample set in the PMSM, respectively, \(G\) is the fault motor sample generator, \(F\) is the healthy motor sample generator, \(D_{X}\) is the healthy motor sample discriminator, and \(D_{Y}\) is the fault motor sample discriminator. As previously mentioned, the network establishes a cycle consistency structure to ensure that the generator migrates the characteristics of the fault motor samples to the input healthy motor samples instead of simply copying the fault motor samples. Taking the healthy motor sample as an example, after the fault motor sample generator \(G\) migrates the fault features to the healthy motor sample, the sample shall still retain its original features; that is, after the transformation of the healthy motor sample generator \(F\), the sample shall be as consistent as possible with its initial value. The 1 norm of the difference between the two shall be used as the loss function \(Loss_{Cycle}\) as follows:  
\[Loss_{Cycle}=\mathbb{E}_{x\in X}[\|F(G(x))-x\|_{1}]+\mathbb{E}_{y\in Y}[\|G( F(y))-y\|_{1}] \tag{9}\]  
Figure 3: Block diagram of Cycle GAN model. To ensure that the input and output samples of the generator are different in style and the same in content, Equation (6) should be satisfied to reduce the \(Loss_{Cycle}\) as much as possible. In the actual training, the following problems were found: the fault motor sample generator \(G\) directly copied the actual fault motor sample \(y\) instead of migrating the fault features to the input healthy motor sample \(x\) to generate \(y^{\prime}\). Since the copied sample \(y\) is indeed a fault sample, discriminator \(D_{Y}\)'s evaluation branch \"encourages\" the fault motor sample generator \(G\) to do so. Once the healthy motor sample generator \(F\) converts the fault motor sample \(y\) into the healthy sample \(x\), it bypasses the loss function \(Loss_{Cycle}\), which is equivalent to \"shielding\" the error of the fault sample generator \(G\), which is contrary to our original intention. Therefore, we set the identification loss function \(Loss_{identity}\) to hope that the generator can also have a discrimination ability for the samples it inputs.