## 4 Image Classification-Based Rail Defect Detection
### Cnn  
CNNs have been widely utilized in the field of SHM regarding vision-based approaches [27; 33; 34]. Such machine learning algorithms have the advances in processing image datasets and achieving high accuracy in multi-class tasks. The general input for such networks is in the format of a tensor with the shape of (height) \(\times\) (width) \(\times\) (number of inputs) \(\times\) (input channels). By arranging the CNN layers for specific circumstances, better performance on the validation set can be obtained.  
The layer structure of the proposed CNN and the names for each layer in this study are shown in Figure 12. A total of three convolution layers, two max-pooling layers and one average-pooling layer have constructed the main computation procedures. The convolution layers function as the feature extraction processors. Specifically, they extract the useful information from an image and translate it into a feature map. The convolution computation is defined as an integration of two functions with one of them being reversed and shifted. For the convolution of 2-D images, it can be comprehended that the target image, which is the input of this layer, is convolutionally calculated with a specifically chosen kernel function. Then a new image is generated which is called a feature map. For this case with RGB images, 3 convolutional kernels are generated for each convolutional layer to process the inputs.  
Figure 11: The imaging data pre-processing: (**a**) 2-D spectrogram with a color bar; (**b**) the extracted RGB image as the input of CNN.  
Figure 10: The 3-D spectrogram of the UGW data acquired by FBG.  
The pooling process is set to reduce the dimensions of data by using a tiling unit, which combines the outputs of the previous layer into clusters. This operation is extremely significant for preventing the network from over-fitting and gradient-disappearing. Lastly, a fully connected layer and a SoftMax layer process the output of the results transmitted from the above layers and reshape the 3D outputs into 1D outputs, as commonly seen in regular neural networks. The classification layer outputs the results, which in this case is the health condition: 'Intact', 'Cracked', and 'Bump', which have been encoded into float digits '0', '1', and '2'.  
The specific parameters for each layer are listed in Table 2 below. To avoid the gradient-disappearing and over-fitting problems, the depth of the network has been strictly reduced considering that the size of the input data is limited.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Network Layer** & **Layer Name** & **Parameters** \\ \hline Input layer & ‘Input’ & Input image size = (32, 32, 3) \\
2-D Convolution layer & ‘ConvInp’ & net width = 16, filter size = 3, padding mode = ‘same’ \\ Batch normalization layer & ‘BNInp’ & minimum batch number = 16 \\ Relu layer & ‘reluup’ & Relu activation function \\
2-D Convolution layer & ‘Conv1’ & net width = 16, filter size = 1, padding mode = ‘same’ \\
2-D Max pooling layer & ‘Pool1’ & pool size = 2 \\ Relu layer & ‘reluup’ & Relu activation function \\
2-D Convolution layer & ‘Conv2’ & net width = 16, filter size = 1, padding mode = ‘same’ \\
2-D Max pooling layer & ‘Pool2’ & pool size = 2 \\ Relu layer & ‘relu2’ & Relu activation function \\ Average pooling layer & ‘globalPool’ & pool size = 8 \\ Fully connected layer & ‘fcFinal’ & output size = 3 \\ Softmax layer & ‘softmax’ & Softmax activation function \\ Classification layer & ‘Output’ & number of classes = 3 \\ \hline \hline \end{tabular}
\end{table}
Table 2: The layer settings of the proposed CNN.  
Figure 12: The CNN layer graph.