# Multi-Scale Rolling Bearing Fault Diagnosis Method Based on Transfer Learning
## 3 Methods
### Overview of the Proposed Model's Architecture
Through the learning of these two linear layers, the network is capable of capturing complex non-linear relationships in the input sequence. The introduction of an activation function contributes to incorporating non-linear factors, thereby enhancing the network's expressive capacity. Ultimately, \(weight_{net}\) outputs a weight matrix for dynamic convolution, the shape of which is determined by the quantity of output channels, input channels, and convolutional kernels. Figure 5: The designed MBDCNet structure. \[weight_{net}=view(Linear(ReLU(Linear(mean(x)))),batchsize,out_{channels},in_{channels}, kernelsize),\] (2) \[out=view(Conv1d(view(x),weight_{net}),batchsize,out_{channels}),\] (3) Among them, \(mean(x)\) represents the average value of the input sequence \(x\) along the channel dimension; \(Linear\) denotes a linear layer; \(ReLU\) represents the activation function and \(view\) refers to the tensor reshaping operation; \(Batchsize\) indicates the batch size; \(out_{channels}\) represents output channels; \(in_{channels}\) denotes input channels; and \(Conv1d\) signifies a one-dimensional convolution operation. During the forward propagation process, this dynamic convolution module performs a one-dimensional convolution operation on the input sequence using the dynamically generated weight matrix, thereby producing an output tensor, as illustrated in Equation (3). This design enables the model to dynamically modify the kernels' weights based on the varying characteristics of the input sequence, thereby achieving high adaptability to spatiotemporal changes. By introducing this dynamic feature, the module possesses a more flexible receptive field, allowing it to more effectively grasp both local and global characteristics within inputs, thus exhibiting excellent performance in processing complex, dynamic data. This design endows the dynamic convolution module with robust performance across a variety of application scenarios. ### Design and Implementation of Loss Function

During the model pre-training phase, our target loss function comprises two components: CORAL [34] and cross-entropy loss. The combined application of these two loss functions aims to enhance the model's generalization performance across different domain data. CORAL loss is used to measure the feature distribution differences between the source and target domains, with its mathematical expression shown in Equation (4). Cross-entropy loss is a commonly used loss function for multi-class classification tasks. For the model's predicted probability distribution \(P\) and actual categories \(Y\), the mathematical expression of cross-entropy loss is as illustrated in Equation (5). \[CORAl_{loss}(X_{s},X_{t})=\frac{1}{4D^{2}}||C_{s}-C_{t}||_{F}^{2}, \tag{4}\]

Here, \(X_{s}\) and \(X_{t}\) represent the feature representations of the source and target domains, respectively, while \(C_{s}\) and \(C_{t}\) are their covariance matrices. The notation \(||\cdot||_{F}\) denotes the Frobenius norm of the matrix. \[CrossEntropy_{loss}(P,Y)=-\sum_{i=1}^{c}y_{i}log(\hat{y_{i}}), \tag{5}\]

Among them, \(y_{i}\) represents the \(i\)th element of the true label, and \(\hat{y_{i}}\) denotes the probability of the \(i\)th category as predicted by the model. \[Loss=CORAl_{loss}+CrossEntropy_{loss}. \tag{6}\]

The integrated utilization of these two loss functions facilitates the model in learning shared feature representations across different domains and enhances its generalization performance, as illustrated in Equation (6). In the transfer phase, we propose a novel loss function for the fine-tuning of the parameters, as shown in Equation (7). Figure 4.0

Among them, \(N\) represents the number of samples, \(i\) denotes the \(i\)th sample, \(p_{i}\) is the model's predicted probability for sample \(i\), and \(y_{i}\) is the actual label for \(i\). From Equation (7), it can be observed that we have modified the loss function based on cross-entropy by introducing new elements, thereby designing a more comprehensive and adaptive loss function.