# Research Method for Ship Engine Fault Diagnosis Based on Multi-Head Graph Attention Feature Fusion
## 2 Related Work and Theory
### Data Topology Construction
#### 2.1.1 Probabilistic Graph Structure  
Inspired by the T-SNE method [25], in this paper, we use the conditional probability calculated by transforming the distance between the data to represent the correlation between the data, and the correlation \(Cor\big{(}x_{i},x_{j}\big{)}\) serves as the degree of correlation between the data samples \(x_{i}\) and \(x_{j}\), and the larger \(Cor\big{(}x_{i},x_{j}\big{)}\) is, the higher the likelihood that \(x_{i}\) will be a neighbor of \(x_{j}\).  
For a dataset \(X=\{x_{1},x_{2},x_{3}\ldots x_{n}\}\), the conditional probability (denoted as \(p_{j|i}\)) between any pair of sample points, \(x_{j}\) and \(x_{j}\), is expressed by Equation (1):  
\[p_{j|i}=\frac{\exp\big{(}-\|x_{i}-x_{j}\|^{2}/2\sigma_{i}^{2}\big{)}}{\sum_{k \
eq i}(-\|x_{i}-x_{k}\|^{2}/2\sigma_{i}^{2})}, \tag{1}\]  
In this context, when both \(p_{j|i}\) and \(q_{j|i}\) are set to \(0\), \(\sigma_{i}\) represents the Gaussian variance centered on point \(x_{i}\). It is worth noting that because data density can vary, there is no universally optimal value for \(\sigma_{i}\) across all datasets. The entropy of this distribution increases as \(\sigma_{i}\) grows larger, so a binary search approach is employed to determine the appropriate value of \(\sigma_{i}\). Perplexity (denoted as \(Per(P_{i})\)) is defined as the metric for computing \(\sigma_{i}\) and typically falls within the range of [5; 50]. Its definition is as follows:  
\[Per(P_{i})=2^{H(P_{i})}, \tag{2}\]  
By specifying a perplexity range as described earlier, the information entropy \(H(P_{i})\) in the equation above is calculated using the following definition:  
\[H(P_{i})=-\sum_{j}p_{j|i}\log_{2}p_{j|i}, \tag{3}\]  
In the low-dimensional space, the symbol \(q_{j|i}\) is employed to denote the conditional probability between samples and to symbolize the data correlation \(Cor\big{(}x_{i},x_{j}\big{)}\), as shown in Equation (4):  
\[Cor\big{(}x_{i},x_{j}\big{)}=q_{j|i}=\frac{\exp\big{(}-\|y_{i}-y_{j}\|^{2} \big{)}}{\sum_{k\
eq i}(-\|y_{i}-y_{k}\|^{2})}, \tag{4}\]  
We utilize the KL divergence to quantify the level of concurrence between \(q_{j|i}\) and \(p_{j|i}\). When the KL divergence is \(0\), it signifies that \(q_{j|i}=\ p_{j|i}\), signifying that \(y_{i}\) and \(y_{j}\) in the low-dimensional space precisely mirror the correct degree of correlation between data points \(x_{i}\) and \(x_{j}\) in the high-dimensional space. The KL divergence is defined as Equation (5):  
\[C=KL\big{(}P_{i}\|Q_{i}\big{)}=\sum_{i}\sum_{j}p_{j|i}\log\frac{p_{j|i}}{q_{j |i}}, \tag{5}\]  
The KL divergence is minimized through the process of gradient descent:  
\[\frac{\delta C}{\delta y_{i}}=2\sum_{j}\Big{(}p_{j|i}-q_{j|i}+p_{i|j}-q_{i|j} \Big{)}\big{(}y_{i}-y_{j}\big{)}, \tag{6}\]  
After the above formula, the degree of correlation between the two samples \(Cor\big{(}x_{i},x_{j}\big{)}\) is calculated, and the larger \(Cor\big{(}x_{i},x_{j}\big{)}\) is, the stronger the correlation between \(x_{i}\) and \(x_{j}\). The probabilistic correlation \(Cor\big{(}x_{i},x_{j}\big{)}\) value between each node constitutes the probabilistic feature matrix \(A_{pp}\):  
\[A_{p}=\begin{bmatrix}p_{11}&p_{12}&\cdots&p_{1N}\\ p_{21}&p_{22}&\cdots&p_{2N}\\ \vdots&\vdots&\ddots&\vdots\\ p_{N1}&p_{N2}&\cdots&p_{NN}\end{bmatrix}, \tag{7}\]