# Structural Damage Detection Based on Real-Time Vibration Signal and Convolutional Neural Network
## 2 Methods
### Convolutional Neural Network  
In this paper, the CNN architecture for classification is shown in Figure 5. The CNN architecture was based on the steel frame and the location of the acceleration measurement points. The CNN included two convolution layers (the first layer had 30 convolution kernels with the size and stride being \(5\times 5\) and 1; the second layer had 60 convolution kernels with the size and stride being \(2\times 2\) and 1), a pooling layer (the size and stride being \(3\times 3\) and 3), a fully connection layer, and an output layer.  
The convolution process was to multiply each element of the convolution kernel with the corresponding element of each sub matrix of the input matrix and then sum them to get an element in a feature matrix as shown in Equation (1):  
\[f(i)=\sum_{n=1}^{v_{k}}S(i+n)K(n) \tag{1}\]  
where the function \(S\) is the input, the function \(K\) is the convolution kernel, \(v_{k}\) is the number of elements in the convolution region, and \(i\) is the number of moves of the convolution kernel. Then, for the convolution kernel slides with a fixed step size, the process was repeated until all elements of the input matrix were involved; finally, it forms the feature matrix (Figure 6). The pooling layer plays a role in reducing the dimension of the input layer. Generally, there were two types of pooling: maximum pooling and average pooling (Figure 7). In this paper, maximum pooling was adopted as it performs better than average pooling [30].  
Figure 5: Convolutional neural network (CNN) architecture.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Damage Scenarios** & **Samples** & **Damage Scenarios** & **Samples** \\ \hline State 0 & 791 & State 4 & 791 \\ State 1 & 791 & State 5 & 791 \\ State 2 & 791 & State 6 & 791 \\ State 3 & 791 & State 7 & 791 \\ Total & & & 6,328 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Samples of the dataset E.  
Activation functions enhance the CNN learning ability. The commonly used activation functions include Sigmoid, tanh, and ReLU (Rectified Linear Unit) (Figure 8). In this paper, ReLU was used, because it behaves better in computations compared with Sigmoid and tanh [31].  
Softmax was the output layer of the CNN, which was used to carry out multi-classification and output the final results predicted by the CNN. The softmax calculation is shown in Formula (2); where \(\mathbf{Z}\) was a vector composed of \(k\) elements, and \(\sigma(z)\) was the probability distribution of each element of the vector.  
\[\sigma(z)_{j}=\frac{\exp\bigl{(}\mathbf{Z}_{j}\bigr{)}}{\sum_{k=1}^{K}\exp( \mathbf{Z}_{k})} \tag{2}\]  
Figure 8: Activation function. (**a**) Sigmoid, (**b**) tanh, (**c**) ReLU.  
Figure 6: Convolution operation.  
Figure 7: Pooling operation.  
where \(j=1,2,\cdots K\), \(\mathbf{Z}=(Z_{1},Z_{2},\cdots,Z_{K})\in\mathbb{R}^{K}\); \(0\leq\sigma(z)\leq 1\), \(\sum_{j=1}^{K}\sigma(z)_{j}=1\). The above formula was applied to solve the problem of multi-label classification in the CNN. The prediction probability of class \(j\) for a given sample vector \(\mathbf{x}\) and weighted vector \(\mathbf{w}\) was  
\[P(y=j|\mathbf{x})=\frac{\exp\bigl{(}\mathbf{x}^{T}\mathbf{w}_{j}\bigr{)}}{\sum _{k=1}^{K}\exp(\mathbf{x}^{T}\mathbf{w}_{k})} \tag{3}\]  
where \(j=1,2,\cdots K\), \(0\leq P(y=j|\mathbf{x})\leq 1\), \(\sum_{j=1}^{K}P(y=j|\mathbf{x})=1\), \(\mathbf{x}\) was the output of the fully connected layer, and \(\mathbf{w}\) was the probability of the connection weights between the predicted output and actual output.  
In order to update the network weights efficiently, the classical stochastic gradient descent method is generally used to optimize the network. This paper adopts a more effective optimization method, adaptive motion estimation (Adam), so as to achieve a more effective recognition effect. Adam is a combination of AdaGrad (gradient algorithm) and Rmsprop (root mean square prop) [32], which combines the advantages of both algorithms: their ability to maintain an adaptive level of learning for each parameter.