# SiamCAM: A Real-Time Siamese Network for Object Tracking with Compensating Attention Mechanism
## 3 Approach
### The Compensatory Attention Model  
There are identical and independent template branches and search branches in the Siamese structure. The template branch extracts only the target features, and the search branch contains both the target and the context. The presence of distractors in the search branch during tracking can affect the judgment of the target by the attention mechanism. Because the search branch has some generalizations to different targets when learning feature attention. It is impossible to distinguish between distractors and targets. Attention to different objects of the same category is usually enhanced simultaneously. Thus we propose to compensate for the autonomously selected channels of search branch attention with the channels of template branch attention selection. The structure of the compensatory attention model is shown in Figure 4.  
As shown above, the template branch network has layer \(i\) features of \(Z^{i}\in\mathbb{R}^{b\times\mathbb{C}\times W\times H}\), and the search branch layer \(i\) feature of \(X^{i}\in\mathbb{R}^{b\times\mathbb{C}\times W\times H}\). The following is an example of \(X^{i}\) to give \(Z^{i}\) and \(X^{i}\) channel attention calculation. We compute the average pooling \(X^{i}_{a}\in\mathbb{R}^{b\times\mathbb{C}\times 1\times 1}\) and maximum pooling \(X^{i}_{m}\in\mathbb{R}^{b\times\mathbb{C}\times 1\times 1}\) on the channel dimension separately using \(X^{i}\). They are downsampled by the fully connected layer, denoted as \({X^{i}_{a}}^{\prime},{X^{i}_{m}}^{\prime}\in\mathbb{R}^{b\times\frac{1}{6} \times 1\times 1}\). The same operation is performed to raise the dimension after activation, denoted as \({X^{i}_{a}}^{\prime\prime},{X^{i}_{m}}^{\prime\prime}\in\mathbb{R}^{b\times \mathbb{C}\times 1\times 1}\). After adding them together to get the pooled feature map \(X^{i}_{p}\), the channel attention weight \(W^{i}_{x}\) is obtained after activation and expansion, i.e.,  
\[X^{i}_{p}={X^{i}_{a}}^{\prime\prime}+{X^{i}_{m}}^{\prime\prime},X^{i}_{p}\in \mathbb{R}^{b\times\mathbb{C}\times 1\times 1}\]  
\[W^{i}_{x}=\sigma(x^{i}_{p})\]  
Similarly, the attention weight \(W^{i}_{z}\) of the template branch feature is obtained. Combination \(W^{i}_{x}\) and \(W^{i}_{z}\) as the final attention weights for the search branch, defined as  
\[W^{i}_{sup}=f(W^{i}_{x},W^{i}_{z})\]  
where \(f(\cdot)\) can use sum \(f_{add}(\cdot)\), dot product \(f_{mul}(\cdot)\), and concatenate \(f_{cat}(\cdot)\). According to the experimental results, the best results can be obtained by connecting the operations. The specific experiments are described in the experimental section of Section 4. Finally, \(W^{i}_{z}\) and \(W^{i}_{sup}\) are weighted on the \(Z^{i}\), and \(X^{i}\) feature maps to obtain a new feature map with reassigned channel weights in the layer \(i\). The specific steps of the compensated attention strategy applied to the search branch are the following Algorithm 1. Figure 4: Compensated attention model for search branch. The experimental results show that the features enhanced by the compensated attention method in this paper have more substantial expressive power and a more fantastic response to the target than the features extracted directly from the original text. Figure 5 shows the feature map after enhancing the compensated attention method. It can be observed from the figure that the features extracted from the limbs of the ants are more explicit after adding the attention mechanism in the fourth column, which shows that the improved feature extraction network extracts more detailed features from the objects. ```
0:\(X^{i},W^{i}_{z}\)
0:\(W^{i}_{sup}\)
1:for i = 1 to N do
2:\(X^{a}_{wh}=avgpooling(X^{i})\). 3:\(X^{m}_{wh}=maxpooling(X^{i})\). 4:\(X^{pool}_{wh}=X^{a}_{wh}+X^{m}_{wh}\). 5:\(W^{i}_{x}=\sigma(X^{pool}_{wh})\). 6:\(W^{i}_{sup}=f(W^{i}_{x},W^{i}_{z})\). 7:if\(f(\cdot)\) is add then
8:\(W^{i}_{sup}=f_{add}(W_{x},W_{z})=\sum_{c=1}^{C}(W^{i,c}_{x}+W^{i,c}_{z})\).