# Intelligent Fault Diagnosis of Unbalanced Samples Using Optimized Generative Adversarial Network
## 3 Results
### Case I: CWRU Dataset
#### 3.1.2 Sample Generation Experiment  
For this case, the learning rate of the generator was 0.0004, and the learning rate of the discriminator was 0.0002 for data generation. There were 64 samples in each batch. In order to maintain the adversarial balance, the updating number of the discriminator and generator is 1:4. The changes in the loss function with the increase in training times are shown in Figure 8. The generator and discriminator gradually stabilized as the training time increased, and the two networks competed, causing large oscillations, as shown in Figure 8a,b. It is seen that the iteration number is more than 13,000. However, in the general trend, the loss function of the generator increased gradually, while that of the discriminator decreased slightly. In the adversarial process, the discriminator beat the generator by a narrow margin. Some synthesized samples are shown in Figure 9.  
To quantitatively analyze the discrepancy between the real and fake images, this study chose histogram matching to calculate the distance between them. Then, the histogram distance \(k_{\text{hm}}\) can be defined by the following:  
\[k_{\text{hm}}=\frac{\sum\limits_{i=0}^{255}\text{min}(H_{1}(i),H_{2}(i))}{ \text{min}(\sum\limits_{i=0}^{255}H_{1}(i),\sum\limits_{i=0}^{255}H_{2}(i))} \tag{14}\]  
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \multirow{2}{*}{**IR**} & \multicolumn{2}{c}{**Normal**} & \multicolumn{6}{c}{**Nine Failure Classes**} & \multicolumn{1}{c}{} \\  & **1** & **2** & **3** & **4** & **5** & **6** & **7** & **8** & **9** & **10** \\ \hline
4:1 & 320 & 80 & 80 & 80 & 80 & 80 & 80 & 80 & 80 & 80 \\
8:1 & 320 & 40 & 40 & 40 & 40 & 40 & 40 & 40 & 40 & 40 \\
16:1 & 320 & 20 & 20 & 20 & 20 & 20 & 20 & 20 & 20 & 20 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Sample sizes of imbalance ratio in Case I.  
Figure 7: Some preprocessed results for Case I.  
where \(H_{1}\) and \(H_{2}\) are the histograms of the images, respectively.  
For RGB image samples, the histogram distance \(D_{\text{hm}}\) is expressed as follows:  
\[D_{\text{hm}}=\frac{1}{3}(k_{\text{hm}}^{R}+k_{\text{hm}}^{G}+k_{\text{hm}}^{B}) \tag{15}\]  
To demonstrate the method's effectiveness, the first sample of each health condition was selected to produce a histogram with R, G, and B channels due to the generated sample similarity. DCGAN was used for the generated sample comparison, and the results of produced histograms are displayed in Figure 8. The histograms with the proposed technique are closer to the actual data than DCGAN for various classes. Although there is a small difference between the real and synthesized samples, Figure 10 also shows that the synthesized samples are learned from real data rather than simple copies. The superior results are further verified, as shown in Figure 11, by comparing the average histogram distance \(D_{\text{hm}}\) of the proposed model and DCGAN. It was observed that most \(D_{\text{hm}}\) of the proposed technique exceeded DCGAN. It was demonstrated that the effectiveness of the synthesized samples using the proposed method was satisfactory.  
Figure 8: Trends of loss functions in Case I: (**a**) trends of the generator loss (\(L_{\text{G}}\)); (**b**) trends of the discriminator loss of generation (\(L_{\text{D},\text{ge}}^{*}\)).  
Figure 9: Some synthesized samples for Case I.  
Figure 10: _Cont._  
Figure 10: Histogram matching comparison of real and synthesized samples in Case I (\(x\) axis denotes the number of bins, and \(y\) axis denotes the frequency in the histogram).