# Transfer Learning Strategies for Deep Learning-based PHM Algorithms
## 4 Case, Transfer of Rotating Machinery Fault Diagnosis Algorithm
### Development of Rotating Machinery Fault Diagnosis Algorithm
#### 4.2.1 Algorithm Design  
(1) Data preprocessing  
The data collected by Case Western Storage University are in MATLAB format (. mat). Each file contains the vibration data of fan end, bearing end and supporting chassis and the speed of motor. We import all the data into Python and store it in a multidimensional array. The data preprocessing of the algorithm includes two parts: data enhancement and standardization. In order to satisfy the amount of data required for the deep learning algorithm training, data enhancement processing is performed on the existing fault data, and sufficient training data is obtained. The fault of the bearing will be reflected in every revolution. Therefore, it is considered that the data collected by the rotation of the motor can record the complete fault mode complete information, and the minimum data length carrying the complete fault mode information is:  
\[L\ =\ \frac{F\times 60}{RPM_{min\ min}} \tag{1}\]  
where \(F\) is the acquisition frequency and \(RPM_{min}\) is the minimum speed in the same batch of data. Segmentation is carried out every \(L_{min}\) data points, and the training data of the k-th fault mode is:  
\[N_{k}\ =\ \frac{n_{k}-L_{min}}{L_{min}} \tag{2}\]  
where \(n_{k}\) is the total amount of data collected by the \(k\)th fault, and \(L_{min}\) is the minimum length of data. Through the above data enhancement method, more training test data can be obtained. Data standardization is based on zero mean and variance normalization. The formula is as follows:  
\[\mathrm{z}= \frac{x-\mu}{\sigma} \tag{3}\]  
where \(\mu\) and \(\sigma\) are the mean and variance of the original data set respectively. Through this standardization, every dimension of data can be subjected to zero-mean and one-variance normal distribution, so that each dimension of data feature dimension is equivalent. In this way, when clustering analysis of neural networks, every dimension is de-dimensionalized, which can avoid the influence of different dimension selection on neural network training. (2) Fault diagnosis network based on CNN network structure  
Compared with the multilayer perceptron (MLP) network, CNN has more prior knowledge of spatial correlation between data. Using a CNN network, three kinds of fault characteristic data can be observed simultaneously, and three kinds of fault feature data can be further combined to make fault diagnosis. The input of CNN can be a multi-dimensional structure, so the three-dimensional vibration data of driver end, fan end and support chassis after data preprocessing are directly sent into the CNN network in three-dimensional form for training. CNN network can extract fault features from original data and classify faults. The number of layers and the number of nodes in each layer are selected based on previous experience on neural network design and cross-checked on the data set. The structure of CNN network is shown in Table 4. It is a more general neural network structure for fault diagnosis. And in order to learn the relationship between two-dimensional vibration data as much as possible, a 2\(\times\)2 convolution kernel is used. (3) Softmax classification layer  
Because the five failure modes of bearings are mutually exclusive, the Softmax regression model is used to achieve multi-classification. The last layer of CNN network structure connects the Softmax classification layer. The function of Softmax is:  
\[P(y\ =\ \dot{i}\big{|}x;\theta)\ =\ \frac{\exp\!\left(\theta_{i}^{T}x\right)}{ \sum_{k\ =\ 1}^{k}\exp\!\left(\theta_{k}^{T}x\right)} \tag{4}\]  
where x is the model input, \(\theta^{1}\), \(\theta^{2},\ldots,\theta^{k}\in\mathbb{R}^{n}\) (The dimension of the feature vector x is n). For training sets \(\left\{\!\left(x^{(1)},y^{(1)}\right),\ldots,\left(x^{(m)},y^{(m)}\right)\! \right\}\), \(y^{(i)}\in\{1,2,\ldots 5\}\), there are five categories in total. For each input x there will be a probability \(P(y\ =\ \dot{j}\big{|}x;\theta)\) for each class.