# A New Defect Diagnosis Method for Wire Rope Based on CNN-Transformer and Transfer Learning
## 3 Methodology
### DCNNT Model  
The intuition of the DCNNT model lies in ViT and the purpose of reducing computational complexity, making it possible to train and predict using a common personal computer while improving the prediction performance. As depicted in Figure 8, the DCNNT model is also a deep learning network based on the CNN and transformer.  
The CNN module is the initial step and its main function is to pre-extract features and reshape \(10\times 10\times 1\) wire rope feature images into a 1D feature sequence to reduce the computational complexity produced during the latter transformer module. The CNN is designed as the backbone network and simply consists of standard convolution, max pooling, and batch normalization stages. As summarized in Table 2, three operation blocks exist, and each block has the same configurations in filter shape. Following the application of the CNN, the size of the feature maps is adjusted from \(10\times 10\) to \(4\times 4\) and the number of channels is increased to 512.  
Pseudo-color is used to visualize the entire data flow process and the color bar is a supplement for reflecting the data values. In the patch embedding stage, we flattened the \(4\times 4\times 512\) feature maps to \(16\times 512\), and each patch become a 512 vector with a trainable  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Layers** & **Filter Shape** & **Output Size** \\ \hline Conv-1 & \(3\times 3\) conv, stride 1, padding 1 & \(10\times 10\times 64\) \\ Normal-1/Pooling-1 & \(3\times 3\) conv, stride 1, padding 0 & \(8\times 8\times 64\) \\ Conv-2 & \(3\times 3\) conv, stride 1, padding 1 & \(8\times 8\times 256\) \\ Normal-2/Pooling-2 & \(3\times 3\) conv, stride 1, padding 0 & \(6\times 6\times 256\) \\ Conv-3 & \(3\times 3\) conv, stride 1, padding 1 & \(6\times 6\times 512\) \\ Normal-3/Pooling-3 & \(3\times 3\) conv, stride 1, padding 0 & \(4\times 4\times 512\) \\ \hline \hline \end{tabular} Conv-1 denotes the first layer of the convolution operation. Similarly, normal and pooling are the normalization and max pooling layers.  
\end{table}
Table 2: CNN backbone network architecture for DCNNT.  
Figure 8: The structure of the proposed DCNNT model. Similarly, residual connections are also used to avoid the issues of vanishing gradients and \(\oplus\) is a part of this residual block providing a shortcut during gradient backpropagation.  
linear projection. Similar to the standard transformer, a learnable class token (gray patch) was added to be responsible for the classification task. Meanwhile, standard learnable 1D embeddings were used to add position information. Then, the data flow shape was 17 \(\times\) 512 and the resulting sequence of embedding vectors was fed to the transformer encoder. The dotted box diagram represents the structure of a single encoder block. Table 3 presents the details of DCNNT encoder variants, twelve encoder blocks were stacked to establish a transformer encoder. The number of multi-head attention networks was set to eight to achieve computationally economic results. The MLP head is a simple linear layer that has the same neural nodes as the diagnosis class.