## 3 Algorithm Improvement
### Improved ShuffleNetv2 Network Module  
#### 3.3.1 Simple and Parameter-Free Attention Mechanism  
The dataset of foreign objects contains interference from non-important features such as complex environmental backgrounds, which is accompanied by a lot of interference information during the recognition process. Redundant information is transmitted during the learning process of the network model, and as the number of network layers increases, the weight of interference information in the feature map also increases, ultimately having a certain negative impact on the model. The attention mechanism is a frequently employed method in the realm of deep learning that allows the model to focus more on key information in the input sequence, thereby improving the accuracy and efficiency of the model. However, existing attention mechanisms suffer from two issues: firstly, they are capable of enhancing features solely in either the channel dimension or the spatial dimension, lacking flexibility in simultaneously adapting to both dimensions. Secondly, their structures are based on a series of complex operations, which can increase the model parameter size and do not fit coal mine edge computing devices.  
The Simple and Parameter-Free Attention Mechanism (SimAM) is an energy-based attention mechanism that can derive 3D attention weights without requiring additional parameters [24]. Compared to other attention mechanisms, SimAM's operations are more concise and clear, effectively avoiding the issue of model parameter increase caused by structural adjustments. Therefore, this paper introduces the attention mechanism SimAM into the ShuffleNetV2 model, which allows the network to focus more on extracting essential feature information from non-coal foreign object images, effectively suppressing  
Figure 5: ShuffleNetV2 unit structure. (**a**) Basic unit structure diagram; (**b**) downsampling unit structure diagram.  
the interference of redundant information on the network. This leads to more efficient feature extraction and reconstruction, improving network recognition accuracy and reducing network complexity.  
Its computational formulas are shown in Equations (6)-(8). SimAM evaluates the importance of each neuron in the network by defining an energy function based on linear separability. Here, \(t\) denotes the target neuron, \(x_{i}\) represents neighboring neurons, and \(\lambda\) is a hyperparameter. \(\hat{\mu}\) and \(\vartheta^{2}\) represent the average and variance of all neurons within the channel, excluding \(t\). The lower the energy, the higher the differentiation between neurons and adjacent neurons, and the higher the importance of neurons.  
\[e_{t}^{*}=\frac{4\big{(}\hat{\sigma}^{2}+\lambda\big{)}}{(t-\hat{\mu}^{2})+2 \hat{\sigma}^{2}+2\lambda} \tag{6}\]  
\[\hat{\mu}=\frac{1}{M}{\sum_{i=1}^{M}}x_{i} \tag{7}\]  
\[\vartheta^{2}=\frac{1}{M}{\sum_{i=1}^{M}}(x_{i}-\hat{\mu})^{2} \tag{8}\]  
Subsequently, each neuron is assigned a unique weighted value based on the manifestation of attention regulation in mammalian brains, as shown in Equation (9) [25]:  
\[\widetilde{X}=\textit{sigmoid}\bigg{(}\frac{1}{E(x)}\bigg{)}\odot X \tag{9}\]  
Within the mathematical expression, \(x\) is the input feature tensor, \(\widetilde{X}\) is the enhanced feature tensor, \(E(x)\) is the sum of \(e_{t}^{*}\) in all channels and spatial dimensions, and \(\odot\) is a dot product operation. By adding a sigmoid function to limit the excessive value of \(E(x)\), the sigmoid function does not influence the comparative importance of each neuron.  
After the input feature map passes through the SimAM, the weight is normalized by the sigmoid function. Then, the weight of the target neuron is multiplied by the characteristics of the initial feature map to derive the ultimate output feature map. The weight distribution of SimAM is shown in Figure 6.