# A Multi-Source Consistency Domain Adaptation Neural Network MCDANN for Fault Diagnosis
## 2 Proposed Model
### Domain Adaptation Network Based on DANN and MK-MMD
}L_{y}\Big{(}G_{y}\Big{(}G_{f}(x_{i})\Big{)},y_{i}\Big{)} +\sum_{i=1,...,N}L_{d}\Big{(}G_{d}\Big{(}R_{\lambda}\Big{(}G_{f}(x_{i})\Big{)} \Big{)},y_{i}\Big{)} \tag{4}\]  
Based on a CNN network consisting of three layers of convolution and pooling, one layer of global average pooling and two fully connected layers, we use a gradient reversal layer to connect a pattern classifier whose output is 2 categories, with the feature extractor to implement a basic domain adaptation network. The basic domain adversarial adaptation network performs well in cross-domain diagnosis of pure signals. In various cross-domain tests, it can achieve nearly 100% accuracy on the target domain, but there is still room for improvement when it comes to the cross-domain performance of noisy signals. For example, on a noisy signal with a signal-to-noise ratio of \(-4\), the classification of the source domain is close to 100%, while the accuracy rate on the target domain is only about 90% on average. Therefore, other methods need to be introduced to assist the domain adversary neural network to find a better feature space. In order to further improve the accuracy of model transfer, it is worthwhile to use appropriate metrics to assist network training based on adversarial theory. In the field of transfer learning, Maximum Mean Discrepancy (MMD) distance is one of the most classic metrics. Map a distribution with a Gaussian kernel function to a point on the corresponding Reproducing Kernel Hilbert Space (RKHS), and the inner product between points can be used to describe the relationship between their corresponding distributions. The expression of MMD distance is as described in Equation (5):  
\[\text{MMD}[F,p,q]:=\sup_{f\in F}\big{(}E_{p}[f(x_{s})]-E_{q}[f(x_{t})]\big{)} \tag{5}\]  
where \(f\) is a function belonging to the function domain \(F\). The intuitive meaning of this formula is to map the data from two fields having different distributions with an arbitrary function from the defined function domain, and then take the maximum value of the expected difference of the two mapped values as the MMD distance. In MMD, the chosen kernel function to map the source domain and the target domain is fixed, and the kernel function such as Gaussian kernel or linear kernel is selected manually. However, manual selection cannot determine which kernel function is suitable for solving the problem. To this end, [PERSON] et al. proposed the MK-MMD distance. That is to use multiple kernels to construct a kernel, the formula of MK-MMD is shown in (6):  
\[d_{k}^{2}(p,q)\triangleq\big{\|}E_{p}[\varphi(x_{s})]-E_{q}[\varphi(x_{t})] \big{\|}_{H_{k}}^{2} \tag{6}\]where \(H_{k}\) is the RKHS obtained by a feature kernel \(k\), which is defined by multiple kernels together, as shown in Formula (7):  
\[K\triangleq\left\{k=\sum_{u=1}^{m}\beta_{u}k_{u}:\beta_{u}\geq 0,\forall u\right\} \tag{7}\]  
Note that the kernel function of MK-MMD is obtained from \(m\) different weighted kernels, and the weight is \(\beta_{u}\). On the basic network structure shown in Figure 2, let the target domain data also participate in the training of the label classifier, and then use the output of each layer in the label classifier as the feature space. Take the feature output of the source domain data and target domain data in these network layers, compute their MK-MMD distance, and incorporate it into the original loss function as part of the loss function. The way to apply the MK-MMD distance is shown in Figure 3, specifically, conv1, 2, 3 are convolutional layers, the gap is the global average pooling layer, fc1, 2 are fully connected layers, and these two feature extraction networks in the figure are actually the same one. A loss is obtained by calculating the mk-mmd distance of the features of different domain data from the gap layer, fc1 and fc2 layers, and added to the overall loss. Compared with the original adversarial network, the adversarial network combined with the MK-MMD distance can achieve a certain accuracy improvement.