# RDD-YOLO: Road Damage Detection Algorithm Based on Improved You Only Look Once Version 8
## 3 The Proposed Method
### SimAM  
In deep learning, an attention mechanism is an approach that mimics the human visual and cognitive system. The attention mechanism assists the recommendation model  
Figure 4: Improved YOLOv8 network architecture. Figure 3: YOLOv8 network architecture. in assigning varying weights to each part of the input, thereby extracting more crucial and significant information and enabling the recommendation model to make more precise assessments. It does not bring more overhead to the calculation and storage of the model [24], thereby enhancing the model's performance and generalization ability. Most existing attention modules typically generate one-dimensional or two-dimensional weights based on the feature X. As shown in Figure 5a,b, these generated weights are expanded into the channel attention mechanism and spatial attention mechanism to refine features in the channel or spatial dimensions. This approach limits their flexibility to learn different attention weights in both channel and spatial dimensions. Moreover, these mechanisms are often constructed based on a series of complex factors, such as the choice of pooling. This paper introduces the SimAM into the backbone network of YOLOv8. The SimAM is a straightforward, parameter-free plug-and-play module [25]. As shown in Figure 5c, it simultaneously considers channel and spatial dimensions, calculates three-dimensional weights through its own defined neuron energy function, and guides the model to focus more on important information with high energy and ignore noise information. This enhances the model's performance and generalization ability without adding any parameters. The calculation steps of the SimAM are as follows:  
SimAM directly infers three-dimensional weights from neurons and then refines these neurons in turn. SimAM defines the following energy function for each neuron:  
\[\mathrm{e}_{t}(w_{t},b_{t},y,x_{i})=(y_{t}-\hat{t})^{2}+\frac{1}{M-1}\sum_{i=1 }^{M-1}(y_{0}-\hat{x}_{i})^{2}, \tag{1}\]  
where \(\hat{t}=w_{t}t+b_{t}\) and \(\hat{x}_{i}=w_{t}x_{i}+b_{t}\) are linear transformations of \(t\) and \(x_{i}\), \(t\) and \(x_{i}\) are the target neuron and other neurons in a single channel of the input feature \(X\in R^{C\times H\times W}\), \(i\) is the index over the spatial dimension, \(M=H\times W\) is the number of neurons on the channel, and \(w_{t}\) and \(b_{t}\) are the weight and bias transformations. All values in Equation (1) are scalars. Equation (1) reaches the minimum when \(\hat{t}\) is equal to \(y_{t}\), all other values of \(\hat{x}_{i}\) are equal to \(y_{0}\), and \(y_{t}\) is not equal to \(y_{0}\). Minimizing this equation allows us to find the linear separability between the target neuron \(t\) and other neurons in the same channel. For simplicity, the final definition of the energy function is obtained by using binary labels (i.e., \(y_{t}=1\) and \(y_{0}=-1\)) and adding regularization factors to Equation (1):  
\[\mathrm{e}_{t}(w_{t},b_{t},y,x_{i})=\frac{1}{M-1}\sum_{i=1}^{M-1}\left(-1-(w_{ t}x_{i}+b_{t})\right)^{2}+(1-(w_{t}t+b_{t}))^{2}+\lambda w_{t}^{2}. \tag{2}\]  
The analytical solution obtained after simplifying the above formula is  
\[w_{t}=-\frac{2(t-\mu_{t})}{(t-\mu_{t})^{2}+2\sigma_{t}^{2}+2\lambda}, \tag{3}\]  
Figure 5: Comparisons of different attention in different dimensions [2]. The identical color signifies the use of a sole scalar applied to every channel, spatial position, or individual point across those features. \[b_{t}=-\frac{1}{2}(t+\mu_{t})w_{t}, \tag{4}\]  
where \(\mu_{t}=\frac{1}{M-1}\sum_{i=1}^{M-1}x_{i}\) and \(\sigma_{t}^{2}=\frac{1}{M-1}\sum_{i}^{M-1}\left(x_{i}-\mu_{t}\right)^{2}\) are the mean and variance computed for all neurons in the channel except for \(t\). The minimum energy can be calculated employing the subsequent formula:  
\[e_{t}^{*}=\frac{4(\hat{\sigma}^{2}+\lambda)}{\left(t-\hat{\mu}\right)^{2}+2 \hat{\sigma}^{2}+2\lambda}, \tag{5}\]  
where \(\hat{\mu}=\frac{1}{M}\sum_{i=1}^{M}x_{i}\) and \(\hat{\sigma}^{2}=\frac{1}{M}\sum_{i=1}^{M}\left(x_{i}-\hat{\mu}\right)^{2}\).