# GAT-ABiGRU Based Prediction Model for AUV Trajectory
## 3 Materials and Methods
### Gat-AbiRgui  
Combining the spatial feature learning capabilities of the graph attention network (GAT) with the temporal analysis strengths of the gated recurrent unit (GRU), we developed a model for predicting autonomous underwater vehicle (AUV) trajectories, termed GAT-ABiGRU, as depicted in Figure 4. This model comprises four distinct layers: the input layer, the GAT layer, the ABiGRU layer, and the output layer. The GAT layer employs a multi-head attention mechanism that effectively learns the spatial features of nodes within the trajectory network, assigning tailored attention weights to each node to enhance the extraction of spatial features by focusing on the most relevant information for each node. The ABiGRU layer combines the advantages of a bidirectional GRU network with an attention mechanism, allowing for comprehensive integration of multiple dimensions of  
Figure 3: GRU structure. input data. This dual approach not only captures the temporal dependencies and long-term trends in AUV trajectories but also enhances the model's ability to accurately forecast future positions of the AUVs, producing valuable trajectory prediction results. In our model, a graph attention network (GAT) layer is employed to capture the spatial features of the nodes within the trajectory network. The input to the GAT consists of a set of nodes, each represented by spatial feature vectors, denoted as \(h=\{h_{1},h_{2},\ldots\ldots h_{N}\}\), \(h_{i}\in\mathbb{R}^{F}\). Here, \(N\) represents the total number of nodes, and \(F\) is the dimensionality of each node's features. The transformation weight matrix \(W\in\times R^{F^{\prime}\times F}\) is utilized to enhance the dimensionality of the input features to \(F^{\prime}\). We implement a self-attention mechanism that is shared among the edges to calculate the attention coefficients between a node and its neighbors. In the aggregation process, we assume that the central node is \(v_{i}\), that the neighbor node is \(v_{j}\), and set the attention coefficient from the neighbor node \(v_{i}\) to \(v_{j}\) as:  
\[\mathrm{e}_{ij}=a\big{(}Wh_{i},Wh_{j}\big{)}, \tag{9}\]  
where a(\(\cdot\)) is the function that computes the correlation between two nodes, while to simplify the computation, we restrict the calculation of this correlation to first-order neighbors. The softmax function, combined with the leaky rectified linear unit (Leaky ReLU) activation function, is used to derive the final normalized attention coefficients. This combination ensures efficient normalization and activation, allowing for a refined adjustment of the attention mechanism's output based on the importance of each feature in the dataset. The formula for this computation is as follows:  
\[\kappa_{ij}=softmax\big{(}leaky\ ReLUe_{ij}\big{)} \tag{10}\]  
Figure 4: GAT-ABiGRU structure. Therefore, through the above calculations, we obtain the attention coefficients between different nodes, and the model features are updated according to the following formula:  
\[\mathrm{h}_{i}^{{}^{\prime}}=\sigma\left(\sum_{j\in N_{i}}\alpha_{ij}Wh_{j} \right), \tag{11}\]  
where \(W\) is the weight matrix of feature multiplication, \(\alpha_{ij}\) represents the strength of attentional relations obtained from the above calculation, \(\sigma\) is the non-linear activation function, and \(j\in N_{i}\) where \(j\) traversed in denotes all nodes adjacent to \(i\). In the following description, \(\sigma\) represents the non-linear activation function. As the multi-head attention mechanism (MHA) has widespread use in image processing and natural language processing tasks, it has increasingly become a focus of research attention [34]. MHA is a mechanism that amalgamates multiple self-attention structures. To address the correlations across various data levels, a multi-head attention mechanism is employed to enhance the stability of feature learning in models [35]. Specifically, we use K-independent attention mechanisms to process the above transformations, each focusing on a different level of information.