# Unsupervised Method Based on Adversarial Domain Adaptation for Bearing Fault Diagnosis
## 2 Preliminary Knowledge
### Model 1: Domain Adversarial Neural Network (DANN)  
Model 1 is a domain adaptation-based unsupervised adversarial learning model, which has been widely applied in image classification but is hardly used in fault diagnosis [38]. As a result, this model has limited generalization ability, which is particularly crucial in fault diagnosis as the source data utilized to train the model may be sparse or not adequately representative of the situations the model will encounter in the real world. Additionally, using adversarial domain training would help the model to be more robust and less sensitive to variations in the data, which is essential in fault diagnosis where data may be noisy or incomplete. This model comprises three main structures: feature extractor, label predictor, and domain discriminator. The feature extractor in this network is a critical component. This feature extractor includes a \(5\times 5\) convolutional layer, a batch normalization, a max pooling, an activation function Relu, 2 standard residual blocks with 64 and 128 channels, respectively, and adaptive average pooling. A standard residual block includes a residual mapping involving two 3 \(\times\) 3 convolutional layers, a Relu activation function, and an identity containing a 1 \(\times\) 1 convolutional layer. It is trained to withdraw useful characteristics from raw data. The label predictor is trained to classify input data according to their labels. The domain discriminator is also a neural network trained to predict the domain of input data.  
The entire model 1 structure is depicted in Figure 1. This model comprises three main structures: feature extractor, label predictor, and domain discriminator, which are described by \(\theta_{y}\), \(\theta_{f}\), and \(\theta_{d}\), respectively. During training, the feature extractor and the domain discriminator are trained simultaneously. Firstly, the feature extractor withdraws the input data features before passing them to the domain discriminator. This structure is trained to determine whether the data is from the source or target domain according to the features. It aims to categorize the input data into source or target domains and minimize loss \(L_{d}(\theta_{d})\). However, the objective of the feature extractor is extracted features that cannot help the domain discriminator accurately classify input data into corresponding domains, so an adversarial relationship is formed. To achieve both goals, a gradient reversal layer is located in the middle of the domain classifier and the feature extractor. After applying this layer, the object is to maximize the domain discriminator loss \(L_{d}(\theta_{f}\),\(\theta_{d})\) during backpropagation. If the domain discriminator cannot correctly divide input data into the source or target domain, the feature extractor will be successful as the data from the source domain and target domain have been mixed in a particular space and cannot be separated. In addition, to ensure that the characteristics withdrawn by the feature extractor can be utilized to conduct classification, the label predictor will conduct supervised training on the labeled source data and be optimized by minimizing the prediction loss \(L_{c}(\theta_{f}\),\(\theta_{y})\). The detailed formulas are shown below:  
\[L(\theta_{f},\theta_{y},\theta_{d})=L_{c}(\theta_{f},\theta_{y})-\gamma*L_{d}( \theta_{f},\theta_{d}), \tag{1}\]  
\[(\theta_{f}^{*},\theta_{y}^{*})=\operatorname*{arg\,min}_{\theta_{f},\theta_{ y}}L(\theta_{f},\theta_{y},\theta_{d}^{*}) \tag{2}\]  
\[(\theta_{d}^{*})=\operatorname*{arg\,max}_{\theta_{d}}L(\theta_{f}^{*},\theta_ {y}^{*},\theta_{d}) \tag{3}\]  
where \(\gamma\) means a self-adaptive weighting parameter, and n denotes the present training number, which is specified below:  
\[\gamma=\frac{2}{1+e^{-10s\mu}}-1 \tag{4}\]  
Figure 1: Structure of DANN.