## 2 Theoretical Method Introduction
### Maximum Mean Discrepancy (MMD)  
The MMD algorithm is a loss function widely used in transfer learning. It is mainly used to measure the distance of the distribution of two different but related sample data and observe the distribution differences in the two types of sample data [45]. In the proposed DCGAN method, MMD is used to measure the similarity between generated samples and original samples. The smaller the MMD, the better the similarity between the generated sample and the original sample, and the higher the quality of the generated samples. MMD mainly uses high-dimensional mapping functions to find the expected difference in RHKS of the two samples to determine the similarity [46]. Assume the samples obey the \(p\) distribution \(D_{s}=\{x_{1},x_{2},\cdots,x_{n}\}\) and the samples obey the \(q\) distribution \(D_{m}=\{y_{1},y_{2},\cdots,y_{m}\}\), function \(\phi:\chi\to H\) maps samples to high-dimensional RKHS, where \(\chi\) is the feature space of the sample. The distribution of different samples in RKHS is effectively matched by means of kernel mean embedding. The unbiased estimation of the kernel average embedding is obtained by calculating the expected value \(E_{p}[\phi(x_{i})]\) and \(E_{q}[\phi(y_{i})]\) of the sample mapped to the RKHS. \(\phi(x_{i})\) is the representation of sample \(x_{i}\) mapped to RKHS through high-dimensional functions. MMD is expressed as follows:  
\[\text{MMD}^{2}(p,q)\triangleq\sup_{\phi\in H}\lVert E_{p}[\phi(D_{n})]-E_{q}[ \phi(D_{m})]\rVert_{H}^{2}=\lVert\frac{1}{n}\underset{i=1}{\overset{n}{ \underset{i=1}{\sum}}}\phi(x_{i})-\frac{1}{m}\underset{j=1}{\overset{n}{ \underset{i=1}{\sum}}}\phi(y_{j})\rVert_{H}^{2} \tag{4}\]  
RKHS is a complete high-dimensional inner product space. Dot product operations of \(\phi(x_{i})\) and \(\phi(y_{j})\) can be calculated with kernel function. Generally, the Radial Basic Function (RBF) is chosen to represent the infinite dimensions Gaussian kernel:  
\[\left\langle\phi(x_{i}),\phi(y_{i})\right\rangle_{H_{k}}=k(x_{i},y_{j})=exp(- \lVert x_{i}-y_{i}\rVert^{2}/\sigma) \tag{5}\]  
where \(\sigma\) represents the bandwidth of the Gaussian kernel. We rewrite Equation (5) by Equation (4):  
\[\text{MMD}^{2}(p,q)\triangleq\lVert\frac{1}{n}\underset{i=1}{ \overset{n}{\underset{i=1}{\sum}}}\phi(x_{i})-\frac{1}{m}\underset{j=1}{ \overset{n}{\underset{i=1}{\sum}}}\phi(y_{j})\rVert_{H_{k}}^{2} \tag{6}\] \[=\frac{1}{n(n-1)}k(x_{i},y_{j})+\frac{1}{m(m-1)}\underset{i\
eq j }{\overset{n}{\underset{i=1}{\sum}}}k(y_{i},y_{j})-\frac{2}{nm}\underset{i \
eq j=1}{\overset{n,m}{\underset{i=1}{\sum}}}k(x_{i},y_{j})\]  
It can be seen from Equation (6) that when \(p=q,\text{ MMD}^{2}(p,q)\) and when \(p\
eq q\), it needs to find the mapping function \(k(\cdot)\) to minimize the \(\text{MMD}^{2}(p,q)\), so that the probability distributions of the two samples in RKHS are more similar under the representation \(\phi(\cdot)\)  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Layer Type** & **Activation** & **Kernel Number** & **Kernel Size \(\times\) Stride** & **Output Size** \\ \hline Input & & & & (1024, 1) \\ Conv1 & ReLU & 20 & 32 \(\times\) 8 & 125 \(\times\) 1 \(\times\) 20 \\ BN & & & & 125 \(\times\) 1 \(\times\) 20 \\ Pool & & 20 & 2 \(\times\) 2 & 62 \(\times\) 1 \(\times\) 20 \\ Conv & ReLU & 20 & 3 \(\times\) 1 & 62 \(\times\) 1 \(\times\) 20 \\ BN & & & & 62 \(\times\) 1 \(\times\) 20 \\ Pool & & 20 & 2 \(\times\) 2 & 31 \(\times\) 1 \(\times\) 20 \\ Conv & ReLU & 20 & 3 \(\times\) 1 & 31 \(\times\) 1 \(\times\) 20 \\ BN & & & & 31 \(\times\) 1 \(\times\) 20 \\ Pool & & 2 to reduce the distribution difference in RKHS. In the Improved DCGAN method, new fault samples are generated by the Generative Adversarial Network, and MMD is used to measure the similarity between generated samples and real samples. The smaller the MMD, the better the similarity between the generated sample and the original sample.