# Lightweight Deep Learning for Road Environment Recognition
## 3 Proposed Method
### Lightweight Residual Convolutional Attention Network  
The central focus of the attention mechanism is to get the network to pay attention to the features it needs to pay more attention to. When we use convolutional neural networks to process images, it is impossible for us to manually adjust what needs attention, and this is when it becomes extremely important to make the convolutional neural network  
Figure 1: Lightweight system for object detection and lane semantic segmentation. pay attention to important objects adaptively. The attention mechanism is one way to achieve adaptive attention of the network. The lightweight residual convolutional attention network (LRCA-Net) proposed in this work is an improved attention mechanism proposed in this study for improving accuracy. Early on, attentional mechanisms were analyzed from brain imaging mechanisms, using the winner-takes-all [30] mechanism to study how to model attention. In deep learning, it is now more important to build neural networks with attention mechanisms, because they can focus on more detailed information about the target and suppress the interference from other useless information. In convolutional neural networks, visual attention is usually divided into two forms: channel attention and spatial attention. The CBAM [27] consists of a serial connection between the channel attention module and the spatial attention module. It can calculate the attention map of the feature map from both channel and spatial dimensions, and then multiply the attention map with the input feature map to perform adaptive learning of features. The LRCA-Net proposed in this paper is an improved module based on CBAM. The overall structure is shown in Figure 2. First, the idea of residuals is added to the network architecture of the CBAM module, and the original features \(F\) and the features \(F^{\prime\prime}\) after CBAM are directly summed and fused. Second, the fully connected layer of the channel attention module is replaced by using 1D convolution. It can be seen that the input feature map \(F\) has a shape of H \(\times\) W \(\times\) C after the channel attention module \(A_{c}\) to get the attention weight \(A_{c}(F)\) with the shape of \(1\times 1\times\) C. Then, \(A_{c}(F)\) and \(F\) are multiplied to get the feature F\({}^{\prime}\), as shown in Equation (1). \(F^{\prime}\) then goes through a spatial attention mechanism \(A_{s}\) to the attention weight \(A_{s}(F)\) with the shape of H \(\times\) W \(\times\) 1. Then, \(A_{s}(F)\) and \(F^{\prime}\) are multiplied to get the final feature \(F^{\prime\prime}\), the shape of \(F^{\prime\prime}\) is H \(\times\) W \(\times\) C, as shown in Equation (2). After a series of processing, the shape of the feature does not change, so this attention mechanism can be inserted after any feature, the network does not need to make changes. Finally, the output feature \(F^{\prime\prime\prime}\) is obtained by summing \(F\) and \(F^{\prime\prime}\) using the residual idea, as shown in Equation (3). \[F^{\prime}=F\times A_{c}(F), \tag{1}\]  
\[F^{\prime\prime}=F^{\prime}\times A_{s}(F^{\prime}), \tag{2}\]  
\[F^{\prime\prime\prime}=F^{\prime\prime}+F, \tag{3}\]  
where \(F\) is the input feature map, \(F^{\prime\prime}\) is the spatial-refined feature, and \(F^{\prime\prime\prime}\) is the output feature, \(A_{c}\) is the channel attention module, and \(A_{s}\) is the spatial attention module. In convolution, there will be multiple channels of feature outputs, and some channel features will have a greater impact on the final target, so it is necessary to focus attention on these channels better, and a common practice is global pooling. Two types of pooling--global maximum pooling and global average pooling--are used in the original  
Figure 2: The structure of LRCA-Net. CBAM. As shown in the original channel attention module in Figure 3, the input feature maps are reshaped into (1, 1, C) after max-pooling and averaging pooling, respectively.