# Modal Strain Energy-Based Structural Damage Detection Using Convolutional Neural Networks
## 2 Methods
### Input and Output of CNN Samples  
The CNN input data of a single damage location, i.e., the MSECR of each rod (61 rods), was collected for each damage scenario, and 3 zeros were added, so the input consists of 64 (61 + 3) numbers; an 8 \(\times\) 8 matrix was constructed as the input. In the testing stage, only the MSE of 17 rods was obtained from vibration experiment, so the missing data in the CNN input data were supplemented by numerical simulation data (i.e., the MSECR of Rods 18-61) [39]. This paper used a classification method to detect the single damage location, which was set to different categories, i.e., the intact condition was set to 0, the damage on the element 1 set to 1, the damage on the element 2 set to 2, and so on. For multiple damage detection, each damage scenario was set to a category, i.e., the damage on the rods 1 and 2 set to 1, the damage on the rods 1 and 3 set to 2, the damage on the rods 1 and 17 set to 16, the damage on the rods 2 and 3 set to 15, and so on. To realize the classification, the fully connected layer was followed by a softmax layer which used the softmax function to calculate a probability. The softmax function took the vector \(\mathbf{Z}\) of \(K\) real \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Layer** & **Type** & **Kernel Num.** & **Kernel Size** & **Stride** & **Pad** & **Activation** \\ \hline
1 & Input & None & None & None & None & None \\
2 & Convolution (C1) & 200 & \(3\times 3\) & [1,1] & 0 & Leaky ReLU \\
3 & Max pooling (P) & None & \(2\times 2\) & [1,1] & 0 & None \\
4 & Convolution (C2) & 400 & \(2\times 2\) & [1,1] & 0 & Leaky ReLU \\
5 & FC & None & None & None & None & None \\
6 & Softmax & None & None & None & None & None \\
7 & Classification & None & None & None & None & None \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Structural parameters of the CNN. Figure 6: Convolutional neural network (CNN) framework. C1, C2: Convolution layer; P: Pooling layer; FC: Fully connected layer. numbers as its input and normalizes it into a vector \((z)\), the probability distribution of which consists of \(K\) probabilities. The function is defined by Equation (4). \[\sigma(z)_{j}=\frac{\exp\bigl{(}Z_{j}\bigr{)}}{\sum_{k=1}^{K}\exp(Z_{k})} \tag{4}\]  
for \(j=1\),..., \(K\) and \(\mathbf{Z}=(Z_{1},\ldots,Z_{K})\in\mathbb{R}^{K}\); obviously \(0\leq\sigma(z)\leq 1\) and \(\sum_{j=1}^{K}\sigma(z)_{j}=1\). Applying this function to the CNN, the softmax function was used to solve a multi-classification problem. The predicted probability for the \(j\)-th class for a given sample vector \(\mathbf{x}\) and a weighting vector \(\mathbf{w}\) was:  
\[P\bigl{(}y=j|\mathbf{x}\bigr{)}=\frac{\exp\bigl{(}x^{\mathrm{T}}\mathbf{w}_{j}\bigr{)} }{\sum_{k=1}^{K}\exp(x^{\mathrm{T}}\mathbf{w}_{k})} \tag{5}\]  
for \(j=1\),..., \(K\), where \(0\leq P\bigl{(}y=j|\mathbf{x}\bigr{)}\leq 1\) and \(\sum_{j=1}^{K}P\bigl{(}y=j|\mathbf{x}\bigr{)}=1\); moreover, \(\mathbf{x}\) was the output of the fully connected layer, \(\mathbf{w}\) was the connection weights between the network outputs and target outputs, \(P\bigl{(}y=j|\mathbf{x}\bigr{)}\) was the conditional probability of belonging to the \(j\)-th class, with \(\mathbf{x}\) being the input. A classification layer computed the cross entropy loss for multi-class classification problems with mutually exclusive classes. For typical classification networks, the classification layer must follow the softmax layer. The cross entropy was used to estimate the difference between the target damage location and the predicted damage location, and it is defined in Equation (6) [40]. \[Loss=-\sum_{i=1}^{N}\sum_{j=1}^{K}t_{ij}\ln y_{ij} \tag{6}\]  
In this paper, \(N\) was the number of the damage and intact cases, \(K\) was the number of damage location, \(t_{ij}\) was the indicator that the \(i\)-th sample belongs to the \(j\)-th element (damage location), and \(y_{ij}\) was the output for sample \(i\) for damage element \(j\).