# A Lithology Recognition Network Based on Attention and Feature Brownian Distance Covariance
## 2 Methodology
### Design of the FBDC Modules  
To enhance the accuracy of rock identification models, this study introduces the Feature Brownian distance covariance (FBDC) algorithm, drawing inspiration from the concept of Brownian distance covariance (BDC) [21; 22]. This algorithm precisely assesses the similarity among rock features by computing the inner product between respective BDC matrices [23]. These BDC matrices effectively capture the nonlinear relationships between channels, representing these relationships through the Euclidean distance nonlinear correlation. The FBDC module is integrated into the network as a pooling layer, strategically employed to sharpen the focus on features within rock sample images.  
Figure 3: Improved CBAM.  
For the lithology recognition task, the network receives a color rock image \(z=\mathbf{R}^{3}\) as input, embedded into the feature space as a tensor of dimensions \(h\times w\times d\), where \(h\) and \(w\) denote the height and width of the feature map, and \(d\) represents the number of feature channels. Subsequently, the tensor undergoes reshaping into a matrix \(\mathbf{X}\in\mathbf{R}^{hw\times d}\), wherein each column \(x_{k}\in\mathbf{R}^{hw}\) or row \(x_{j}\in\mathbf{R}^{d}\) can be interpreted as an observation of \(\mathbf{X}\)[24; 25; 26].  
Considering \(x_{k}\) as an instance of a casual observation, the process involves three main steps. Initially, the computation of the squared Euclidean distance matrix \(\tilde{\mathbf{A}}\) takes place. Subsequently, the computation of the Euclidean distance matrix \(\tilde{\mathbf{A}}\) follows. Finally, the BDC matrix \(\mathbf{A}\) is derived by \(\tilde{\mathbf{A}}\) subtracting its row mean, column mean, and the mean of all its elements, as illustrated in Equation (1).  
\[\begin{split}\tilde{\mathbf{A}}=2(\mathbf{1}\Big{(}\mathbf{X}^{T} \mathbf{X}\circ\mathbf{I})\Big{)}_{\text{sym}}-2\mathbf{X}^{T}\mathbf{X}\\ \tilde{\mathbf{A}}=\Big{(}\sqrt{\tilde{a}_{kl}}\Big{)}\\ \mathbf{A}=\hat{\mathbf{A}}-\frac{2}{d}(\mathbf{1}\hat{\mathbf{ A}})_{\text{sym}}+\frac{2}{d^{2}}\mathbf{1}\hat{\mathbf{A}}\mathbf{1}\end{split} \tag{1}\]  
where \(\tilde{a}_{kl}\) is the squared Euclidean distance from the kth column to the lth column of the matrix \(\mathbf{X}\). Furthermore, \(\mathbf{1}\) denotes a matrix with 1 in each row and column, and \(\mathbf{I}\) denotes the unit matrix, which \(\circ\) denotes the Hadamard product. sym is expressed as shown in Equation (2).  
\[(U)_{sym}=\frac{1}{2}(U+U^{T}) \tag{2}\]  
In this study, the rockiness recognition task comprises six classes of test sets denoted as \(S_{k}k\in(1,6)\), each containing \(j\) images. The BDC averaging matrix \(P_{k}\), corresponding to each class of test set \(S_{k}\), is calculated sequentially as illustrated in Equation (3).  
\[\mathbf{P}_{k}=\frac{1}{K}\underset{(z_{j})\in S_{k}}{\sum}\mathbf{A}(\mathbf{ Z}_{j}) \tag{3}\]  
Here, \(\mathbf{Z}_{j}\) represents the set of images within a specific class of test sets.  
The BDC matrix of the input image undergoes an inner product with the BDC average matrix \(P_{k}\) of the corresponding test set to derive the similarity, as outlined in Equation (4).  
\[\rho(\mathbf{X},\mathbf{Y})=<\mathbf{A},\mathbf{P}_{k}>=\mathbf{A}^{T} \mathbf{P}_{k} \tag{4}\]  
Following Equation (4), similarity values are computed for each type of test set. Subsequently, the prototype distance Softmax classifier outputs the classification corresponding to the rock image. Specific matrix calculation parameters are compared to Table 2.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Significance** \\ \hline \(h\) & High \\ \(w\) & Wide \\ \(d\) & Number of feature channels \\ \(\tilde{\mathbf{A}}\) & Square Euclidean distance matrix \\ \(\tilde{\mathbf{A}}\) & Euclidean distance matrix \\ \(\mathbf{A}\) & BDC matrix \\ \(\mathbf{I}\) & Unit matrix \\ \(\circ\) & Hadamard product \\ \(k\) & Categorical quantity \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison table of matrix calculation parameters.