# Grid Anchor Lane Detection Based on Attribute Correlation
## 3 Methods
### Attribute Correlation Loss Function  
The model outputs detection results on feature maps at three different scales. During training, the corresponding labels for each scale are used to compute the loss function, which is then backpropagated. The total loss of the model is the sum of the losses at the top, middle, and bottom layers. Since gradients tend to decrease as they propagate through deeper layers during backpropagation, the contribution of each layer's loss to the overall loss is not equal. \[L=\sum_{s=0}^{2}\alpha_{s}L_{s} \tag{10}\]  
The single-layer loss function \(L_{s}\) measures the error between the predictions at that layer and the corresponding labels. Based on the grid anchor representation of lane lines, the attributes of an anchor consist of two parts: one part indicates the lane line features within the anchor itself, and the other part indicates the continuity relationship between the anchor and its neighboring anchors. According to the composition of the grid anchor information, \(L_{s}\) can be decomposed into two main components: the intra-anchor loss function \(L_{si}\) and the inter-anchor loss function \(L_{so}\). \[L_{s}=L_{si}+L_{so} \tag{11}\]  
From the definition of the attributes of the grid anchor, it can be seen that the first \(n+3\) channel layers represent the existence, instance, and direction attributes, which are associated with classification tasks, while the subsequent three channel layers represent the offset and slope attributes, which are associated with regression tasks. The intra-anchor loss function \(L_{si}\) is composed of a classification part \(L_{si}^{c}\) and a regression part \(L_{si}^{r}\). These  
Figure 7: Illustration of the convolutional reordering upsampling method. During the reordering process, for the data after \(3\times 3\) convolution, the relative positions of the data within the same channel layer remain unchanged, while the data from the same spatial location across different channel layers are sequentially placed into a \(2\times 2\) region according to a specified order. components are calculated based on the model's output values \(A^{s}\) (the first \(n+3\) channel values of \(A^{s}\) are normalized through the _sigmoid_ function) and the corresponding grid anchor labels \(T^{s}\). \(L_{si}^{c}\) and \(L_{si}^{r}\) are accumulated from the attribute loss values of all anchors. \[L_{si}=\alpha_{si}^{c}L_{si}^{c}+\alpha_{si}^{r}L_{si}^{r}, \tag{12}\]  
\[L_{si}^{c}=\sum_{c=0}^{n+2}\sum_{i=0}^{H_{s}-1}\sum_{j=0}^{W_{s}-1} \begin{cases} \beta L_{CE}\big{(}A_{c,ij,i}^{s},T_{c,ij}^{s}\big{)},&T_{0,ij}^{s}=1\\ L_{CE}\big{(}A_{c,ij,i}^{s},T_{c,ij}^{s}\big{)},&T_{0,ij}^{s}=0\end{cases} , \tag{13}\]  
Here, the coefficients \(\alpha_{si}^{c}\) and \(\alpha_{si}^{r}\) represent the proportions of the classification loss \(L_{si}^{c}\) and the regression loss \(L_{si}^{r}\) in the loss function \(L_{si}\), respectively. \(L_{CE}\)[36] represents the binary cross-entropy loss function, and \(\beta\) is to balance the number of positive and negative samples (\(\beta>1\)). \(A_{c,ij,i}^{s}\) and \(T_{c,ij}^{s}\) represent the output value \(A^{s}\) and the label \(T^{s}\) at channel layer \(c\), vertical position \(i\), and horizontal position \(j\), respectively. \[L_{si}^{r}=\sum_{c=n+3}^{n+5}\sum_{i=0}^{H_{s}-1}\sum_{j=0}^{W_{s}-1} \begin{cases} L_{1}\Big{(}A_{c,j,i}^{s},T_{c,ij}^{s}\Big{)},&T_{0,ij}^{s}=1\\ 0&,&T_{0,ij}^{s}=0\end{cases} , \tag{14}\]  
Here, \(L_{1}\) denotes the smooth L1 loss function [37]. For the regression task, it is meaningless to calculate the loss for the offset and slope properties of the background anchor (\(T_{0,i,j}^{s}=0\)), so their loss value is calculated as 0. \(L_{so}\) establishes the attribute correlation between adjacent anchors according to the direction attribute of the label \(T^{s}\). It mainly consists of two components:  
\[L_{so}=\alpha_{si}^{ed}L_{so}^{ed}+\alpha_{si}^{ok}L_{so}^{ok}, \tag{15}\]  
where \(\alpha_{si}^{ed}\) and \(\alpha_{si}^{ok}\) are the proportion coefficients.