# A Rotating Object Detector with Convolutional Dynamic Adaptive Matching
## 3 Method
### Gradient Adaptive Equalization Loss  
Aerial targets often have the characteristics of a high aspect ratio, multi-directionality, and a dense layout. Most mainstream networks have horizontal detection boxes. If directly applied to aerial targets, the detection boxes will contain a large amount of background information, and invalid background information would lead to a decrease in detection accuracy. These mainstream networks adopt a multi-task learning mode, which trains both classification and regression tasks simultaneously. The loss function is defined as follows:  
\[L=L_{cls}(k,u)+\lambda L_{reg}(p,v) \tag{9}\]  
where \(l_{cls}\) and \(l_{reg}\) represent the loss functions for classification and regression, and \(k\) and \(p\) represent the corresponding predicted values. \(u\) and \(v\) are the corresponding labels. \(\lambda\) is a hyperparameter that adjusts the regression loss weight in multi-task learning. The regression loss function usually uses a smooth L1, defined as follows:  
Figure 3: (**a**) Standard convolution for feature extraction (**b**) DCM predicts the rotation angle of convolution (**c**) Rotational convolution for feature extraction. DCM Predicts multiple angle branches with different weights. Weighted sum of these angle branches to predict the rotation angle of multi-directional remote sensing targets. \[\mathrm{L}_{smooth}(x)= \begin{cases}0.5x^{2}&\text{if }|x|<1\\ |x|-0.5&\text{otherwise}\end{cases}  \tag{10}\]  
The partial derivative of Formula (10) is calculated to obtain the gradient function of the smooth L1:  
\[\frac{\partial\mathrm{L}_{smooth}}{\partial x}= \begin{cases}x&\text{if }|x|<1\\ \pm 1&\text{otherwise}\end{cases}  \tag{11}\]  
RS object detection focuses on the accuracy of the regression box. If the weight of the \(\lambda\) is directly increased, it will make the abnormal samples with large gradients and severe background interference in the regression loss more sensitive, which is unfavorable for training. From Formula (11), it can be seen that for the parts with larger gradients, the calculated losses are also larger, which leads to the model paying more attention to abnormal samples. In comparison to abnormal samples, some high-quality samples in aerial targets possess smaller gradients during training, leading to insufficient contributions to the losses. The smooth-L1 loss function did not adequately train this portion of high-quality samples. As shown in Figure 2, a gradient adaptive equalization loss function was designed to improve the stability of the RS detection network. Therefore, we design the gradient adaptive equalization loss function \(L_{gae}\) and first provide the definition of its gradient function:  
\[\frac{\partial L_{gae}}{\partial x}= \begin{cases}a\ln(b|x|+1)&\text{if }|x|<1\\ c&\text{otherwise}\end{cases}  \tag{12}\]  
If the upper limit of the gradient is not set, training will pay more attention to some abnormal samples with large gradients, while ignoring high-quality samples, which will cause uneven training. Therefore, the upper limit of the gradient \(c\) is set. In order to ensure the continuity of the gradient, the relationship between the equilibrium parameters \(a\), \(b\), and \(c\) is as follows:  
\[aln(b+1)=c \tag{13}\]  
From Figure 4a, it can be seen that compared to the smooth L1 gradient function, \(L_{gae}\) amplifies the value of the small gradient, indicating that the network pays more attention to the regression loss of high-quality samples during training. Moreover, as the equilibrium parameter \(a\) increases, the small gradient value also increases without affecting the large gradient value part. Finally, the weight of the high-quality samples in training are increased, the gradient function is integrated, and the loss function \(L_{gae}\) is obtained:  
\[L_{gae}(x)=\left\{ \begin{array}{ll}\frac{a}{b}(b|x|+1)\ln(b|x|+1)-a|x|&\text {if }|x|<1\\ c|x|&\text{otherwise}\end{array} \right. \tag{14}\]  
In this experiment, \(a=0.5\) and \(c=1.5\).