# CASVM: An Efficient Deep Learning Image Classification Method Combined with SVM
## 3 Methods  
### Overview  
Figure 1 shows the model architecture of this paper, in which we combine a CNN with an embedded CA mechanism and SVM for feature learning. The network embedded with an attention mechanism can extract highly representative image features and learn the essential laws of data. The last layer of the CNN outputs the boundary probability of the classification calculated by the linear combination of the output weights and bias terms of the previous hidden layer, for which the CNN hidden layer output has no special significance. Therefore, after learning the features, the output values must be input to a classifier effective in image classification, and SVMs are among the best. Therefore, we combine these methods in CASVM, which outperforms softmax at image classification.  
CASVM is a combination of CNN embedded with CA and SVM; Figure 1 shows the CNN using ResNet18 as an example. We enter an image of size C \(\times\) H \(\times\) W, where C is the number of channels on the feature graph, H is the height, and W is the width. Before the image is sent to the residual (blue) block, convolution is carried out to preserve the feature information as much as possible. The last data normalization in the residual block is entered in the attention block (green box). The feature maps are average pooled along the horizontal and vertical directions, and a factor of r reduces the number of channels of the feature maps. The channels are compressed by concatenation of spatial dimensions and \(1\times 1\) convolution, spatial information in both directions is segmented into feature maps by batch normalization and nonlinear encoding, and the same number of channels as the input is obtained using \(1\times 1\) convolution. A sigmoid function normalizes weight. Subsequent residual blocks are designed to nest the attention block between data normalization and activation, as shown in the first residual block, effectively amplifying the differences between image features to differentiate image classes better. The weight is normalized by a sigmoid function. Subsequent residual blocks embed the attention block between data normalization and activation, effectively magnifying the differences between image features to distinguish image categories better. After residual computation, two fully  
Figure 1: CASVM using ResNet18. Image goes through five residual blocks, with convolutional layer, attention block, and ReLU activation function. Attention block averages pooled data along two directions, reduces number of channels by a factor of r, and uses operations such as \(1\times 1\) convolution to obtain a number of channels equal to the input. Data go into SVM after final residuals for classification.  
connected layers represent classes that divide the images, and a multiclassification SVM loss function learns the network parameters.  
The CASVM model combines the advantages of CNN and SVM with embedded attention mechanisms to outperform a single classifier for image classification. The CNN is an empirical risk minimization model, which can fall into local minima when backpropagation finds the classification hyperplane. SVM is a structural risk minimization model, which can avoid local optima by solving a quadratic programming problem. Hence, its generalization ability is better than that of CNN, and replacing the output layer of CNN with SVM can further improve image classification accuracy.  
A CNN can perform downsampling and convolution on images to extract representative image features, with an attention mechanism to enhance effective information. Attention is focused on the image region with a more significant impact on classification extract more robust image features. Manually designed feature extraction methods may be complex and require more skill, and the extracted features may not be universally valid. DL methods can avoid much manual involvement and extract more significant features than traditional methods, which is the unique advantage of combining DL with SVMs.