# An Attention-Based Network for Textured Surface Anomaly Detection
## 3 Result and Discussion  
All experiments are implemented using Tensorflow [24] and the process is divided into two steps. Firstly, the segmentation network is trained independently, then these optimized parameters are frozen and only classification network are trained in the second stage. Batch normalization [25] is implemented in each convolutional layer. The Adam [26] optimizer and a learning rate of 0.1 are used in this paper. Firstly, the effectiveness of the anomaly attention module is verified from the views that the segmentation results should provide good interpretability as human experts and the optimal performance is liable to achieve. Figure 4a illustrates two examples when the anomaly attention module is used or not used, and the relevant variations of classification score on the test dataset is shown in Figure 4b. \begin{table}
\begin{tabular}{c c c c c} \hline \hline  & & **Train** & **Test** & \\ \hline
**Class** & **Positive** & **Negative** & **Positive** & **Negative** \\ \hline
1 & 79 & 496 & 71 & 504 \\
2 & 66 & 509 & 84 & 491 \\
3 & 66 & 509 & 84 & 491 \\
4 & 82 & 493 & 68 & 507 \\
5 & 70 & 505 & 80 & 495 \\
6 & 83 & 492 & 67 & 508 \\
7 & 150 & 1000 & 150 & 1000 \\
8 & 150 & 1000 & 150 & 1000 \\
9 & 150 & 1000 & 150 & 1000 \\
10 & 150 & 1000 & 150 & 1000 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Sample distribution of the DAGM dataset. Figure 4: _Cont._  
It can be explained that on one side, it can better focus on the object regions for the anomaly attention module than that when only the feature extraction module is applied, and improve the condition that background noises are apt to be erroneously identified as anomalies. On the other hand, due to the interference of the false-alarm blocks, the difficulty in differentiating anomalies from background noises is increased for classification model, which causes us to conclude that the classification network is harder to be optimize as Figure 4b. Then, we report the results of comparative experiments with Compact CNN in Ref. [19] on the original and augmented datasets as depicted in Table 2.  
From Table 2 we can see that Compact CNN is apt to be affected by the imbalance of positive and negative samples, while our model is not very sensitive to this quantity difference and can work well under the two conditions. Therefore, the proposed approach is quite applicable to practical industrial scenarios where defective samples are hard to acquire but numerous defect-free samples are usually available. \begin{table}
\begin{tabular}{c c c c c} \hline  & **Original** & \multicolumn{3}{c}{**Augmented**} \\ \hline
**Class** & **TPR** & **TNR** & **TPR** & **TNR** \\ \hline
1 & 100[100] & 96.4[100] & 100[100] & 98.8[100] \\
2 & 98.8[100] & 99.6[100] & 100[100] & 99.8[100] \\
3 & 100[100] & 97.1[100] & 100[100] & 96.3[100] \\
4 & 77.9[100] & 95.7[100] & 98.5[100] & 99.8[100] \\
5 & 100[100] & 99.6[100] & 100[100] & 100[100] \\
6 & 100[100] & 100[100] & 100[100] & 100[100] \\
7 & 100[100] & 98.9[100] & 100[100] & 100[100] \\
8 & 100[100] & 99.9[100] & 100[100] & 100[100] \\
9 & 100[100] & 100[100] & 100[100] & 99.9[100] \\
10 & 100[100] & 99.7[100] & 100[100] & 100[100] \\ \hline \end{tabular}
\end{table} 
Table 2: Comparative experiments with Compact CNN on original and augmented datasets (Our results are marked with square brackets. TPR: True Positive Rate; TNR: True Negative Rate). Figure 4: (**a**) Test samples of segmentation network (FEM: feature extraction module; AAM: anomaly attention module). The red squares represent the areas erroneously detected due to background interference; (**b**) Relevant test f-score variations in training process of classification network (the initial value is set as 0.9). Figure 5: Examples of segmentation and classification. Finally, more comparative results are listed in Table 3 for widespread comparison and comprehensive analysis.