# Intra-Domain Transfer Learning for Fault Diagnosis with Small Samples
## 2 Methodology
### Fault Diagnosis Model with Intra-Domain Transfer  
Armed with the above intra-domain transfer strategy, in this section, we propose a fault diagnosis model for rotating machinery. Although many types of data (infrared images, temperature sequences, etc.) can be measured, vibration signals are still most prevalent in fault diagnosis applications. Without loss of generality, we assume both the source and the target domain use high frequency non-periodic vibration signals to diagnose faults. Given their enormous capacity to represent knowledge, deep neural networks have been widely adopted as the carrier of knowledge in transfer learning applications. Specifically, convolutional neural networks (CNN) were early choices in the fields of computer vision and industrial fault diagnosis. Hereinafter, we use CNN as the main architecture for fault diagnosis modelling. Again, without loss of generality, we select ResNet-50 as our off-the-shelf inter-domain model since it is a benchmarking model [32]. Notably, the complexity (depth) of the selected model can vary depending on the problem to be solved, especially the complexity of the data input. Since ResNet-50 is trained on natural images, we propose to use continuous wavelet transform (CWT) to convert our vibration signals to time-frequency spectrums, as has been carried out elsewhere [33]. This brings the data in source and target domains into the same format as the distant domain (i.e., images); see Figure 3 for an example. In addition, CWT conducts multi-scale transform on non-stationary signals, and this retains as much information as possible from the input. For simplicity, we select the complex Morlet wavelet as the mother wavelet, defined as:  
\[\psi_{a,\tau}(t)=\frac{1}{\sqrt{a}}\psi\left(\frac{t-\tau}{a}\right) \tag{1}\]  
where \(a\) represents a scale parameter related to frequency, and \(\tau\) is a translation parameter related to time. Figure 2: Illustration of the intra-domain transfer learning strategy. The wavelet coefficients of a signal are calculated by a convolution operation between the mother wavelet function \(\psi_{a,\tau}(t)\) and the signal \(x(t)\), as defined by:  
\[W(a,\tau)=\frac{1}{\sqrt{a}}\int x(t)\psi^{*}\Big{(}\frac{t-\tau}{a}\Big{)}dt \tag{2}\]  
where \(\psi^{*}(\cdot)\) indicates the complex conjugate of function \(\psi(\cdot)\). The signal is decomposed into a series of complex numbers in distinct frequency bands, as shown in Figure 3. The moduli of the complex numbers are calculated and grouped by frequency and time. In this fashion, we get a one-dimensional signal mapping in the time-frequency domain, with the horizontal and vertical axes corresponding to time and frequency, respectively. Next, we conduct three-channel extensions of a time-frequency mapping to produce a time-frequency image. The above time-frequency transformation describes the data preprocessing step of our fault diagnosis model. Once this step is completed, the model performs a vanilla transfer from ResNet-50 to the source domain. As the source domain is data-abundant, negative transfer in this step can be avoided. Studies in computer vision have found the convolutional layers of a CNN are essential for automatic feature learning. The deeper the layers, the more abstract the learned features are, and vice versa. That being said, we propose shallow-layer freezing to ensure feature extractors in the source domain are reused in the target domain. The sharing of feature extractors is supported by assuming the distribution discrepancy between source and target domains is reasonably small. In other words, the weights of those shallow layers in the CNN are fixed to extract features in the target domain (i.e., features shared in common with the source domain). The last step of our fault diagnosis model is finetuning in the target domain. Concretely, the final classification layer (e.g., a soft-max layer) of the CNN is customized to fit the number of classes in the target domain.