# A Fault Detection Framework for Rotating Machinery with a Spectrogram and Convolutional Autoencoder
## 3 Proposed Framework
### Two-Dimensional Convolutional Autoencoder with Spectrogram  
The 2D-CAE model summarizes the input spectrogram into smaller latent feature vectors through the encoder structure, and the latent feature vectors reconstruct the input spectrograms through the decoder structure. The 2D-CAE can successfully handle the spectrogram with both the convolutional and pooling layers. The convolutional layer can accommodate localized characteristics of the input data by using a convolutional kernel filter, and these convolutional kernel filters share weights across all regions of the input data. The output feature map of \(c\)-th channel in the \(l\)-th convolutional layer, \(H_{c}^{l}\), is calculated as follows:  
\[H_{c}^{l}=f\left(\sum_{k=1}^{c^{l-1}}H_{k}^{l-1}*W_{k,\ c}^{l}+b_{c}^{l}\right),\quad c=1,\ 2,\ 3,\ \dots,\ C^{l}, \tag{6}\]where \(H_{k}^{l-1}\) denote the output feature map of \(k\)-th channel in the \((l-1)\)-th layer, which is convolved with the kernel filter \(W_{k,c}^{l}\) of c-th channel in \(l\)-th layer. \(C^{l}\) is the number of channels in the \(l\) layer and \(b_{c}^{l}\) is the bias of \(c\)-th channel in the \(l\)-th layer. In addition, \(*\) denotes the convolutional operator and \(f(\cdot)\) is the activation function for a nonlinear transformation. Consequently, the output feature map having \(C^{l}\) number of channels is obtained. Generally, each of the convolutional layers is followed by its corresponding pooling layer, integrating adjacent values of the feature map into one value. Among various pooling schemes, max-pooling, which chooses the maximum value within a local region of an input feature map, is the most widely used. By doing so, the dimensionality of feature maps and computational complexity can be considerably reduced. These convolutional and max-pooling layer pairs, referred to as a convolutional block, can be repeated multiple times. At the end of the encoder structure, the feature maps generated through multiple convolutional blocks are flattened into a one-dimensional vector and finally mapped to a latent feature vector by the fully connected layer. Then, the input spectrogram is reconstructed from the latent feature vector in the decoder structure. The decoder structure consists of the same number of layers as the encoder structure, arranged symmetrically. That is to say, the latent feature vector is connected to a fully connected layer and reshaped into a two-dimensional feature map. The feature maps are inversely reconstructed using transposed convolutional layers and up-sampling layers instead of convolutional layers and max-pooling layers, respectively. The transposed convolutional layer, also referred to as the deconvolutional layer, enlarges the size of the input feature map as opposed to the convolutional layer in the encoder structure. The input feature map, i.e., the latent feature vector, is transformed by a transposed convolutional layer as follows:  
\[\widetilde{H}_{c}^{l}=f\left(\sum_{k=1}^{C^{l-1}}\widetilde{H}_{k}^{l-1} \oplus\widetilde{W}_{k,c}^{l}+\widetilde{b}_{c}^{l}\right),\quad c=1,\;2,\;3, \;\ldots,\;C^{l}, \tag{7}\]  
where \(\bar{\bar{\phantom{\bar{\phantom{\bar{  
and enhance the efficiency of training a network structure. In addition, the BN scheme helps to improve the generalization performance of DNN structures [65]. Therefore, this study applied the BN scheme as a layer into our proposed feature extractor, 2D-CAE, to improve feature extraction performance. In our proposed framework, the weights of the convolutional blocks and the fully connected layer within the 2D-CAE are trained using the Adam optimization algorithm by minimizing the MSE loss function between the input spectrogram and its reconstructed one. When the reconstruction error gets significantly low and converges to a certain level, the training procedure of the 2D-CAE is terminated.