# Infrared Fault Classification Based on the Siamese Network
## 3 Methodology
### Adaptive Coordinate Attention  
In response to the high similarity between images, it is necessary to effectively learn the effective areas of different failures, and this improvement introduces the coordinate attention mechanism. The coordinate attention mechanism not only considers channel information but also position information related to the direction, providing it with sufficient flexibility and robustness. The illustration of the improved coordinate attention mechanism is shown in Figure 3.  
First, input the feature maps using 1 \(\times\) 1 and 3 \(\times\) 3 convolutional layers, and then concatenate the output of these layers using a concatenate layer with a size of (\(C,H,W\)) to obtain a total of \(C\) features. Next, apply a 3 \(\times\) 3 convolutional layer with a stride of 2 to obtain higher-level features with \(C\)\(\times\) 3 \(\times\) 3 dimensions. Use a convolutional layer with a kernel size of (\(H\), 1) and (1, \(W\)) to pool the feature maps, resulting in \(C\)\(\times\) 1 \(\times\)\(W\) and \(C\)\(\times\)\(H\)\(\times\) 1 feature maps, each with a size of \(C\)\(\times\) 1 \(\times\)\(W\) and \(C\)\(\times\)\(H\)\(\times\) 1, respectively. Finally, use a pool layer with a size of (\(C\), \(H\), 1) to pool the output of the last convolutional layer, resulting in \(C\)\(\times\) 1 \(\times\)\(W\) feature maps with a size of \(C\)\(\times\)\(H\)\(\times\) 1. The output of the \(C\)-th channel in the height dimension is defined as:  
\[Z_{c}^{h}(h)=\frac{1}{W}\,x_{c}(h,i), \tag{1}\]  
Figure 2: Architecture of the proposed ACA-FFM Siamese network.  
and the output of the C-th channel in the width dimension can be represented as:  
\[Z_{c}^{w}(w)=\frac{1}{H}\,x_{c}(j,w). \tag{2}\]  
After the above transformation, the features extracted from the two directions are concatenated and convolutionally transformed, and a nonlinear activation function, as shown in Equation (3), is used for activation.  
\[f=\delta\Big{(}F_{1}\Big{(}\Big{[}z^{h},z^{w},\Big{]}\Big{)}\Big{)}, \tag{3}\]  
where \([z^{h},z^{w}]\) denotes the assembly process, and the \(F_{1}\) step involves convolution translation, with \(\delta\) being a nonlinear activation function. Building upon this foundation, the output values of function \(f\) are processed by high-level and low-level convolution operations with Sigmoid functions, resulting in two output locations, as shown in Equation (4).  
\[\left\{\begin{array}{l}g^{h}=\sigma\Big{(}F_{h}\Big{(}f^{h}\Big{)}\Big{)}\\ g^{w}=\sigma(F_{w}\Big{(}f^{w}\Big{)}\end{array}\right. \tag{4}\]  
After obtaining \(g^{h}\) and \(g^{w}\), the features maps \(A1\), \(A2\), and \(A3\) are obtained by multiplying \(U1\), \(U2\), and \(U\) with \(g^{h}\) and \(g^{w}\), respectively. These maps, essentially, represent the information output by convolutions with different receptive fields. Finally, these three feature maps are merged to obtain the final output feature map \(X1\).  
Compared to the traditional attention module, the ACA module can dynamically adjust the sensitivity field of the module, enhancing the capability of multi-scale feature extraction. In the coordinate attention part, spatial feature clusters are formed along two directions, generating two feature graphs with direction sensitivity. While storing location information in one direction, the network captures the long-term dependencies of the other direction, assisting in obtaining more precise effective feature information.