# Robust Beamforming Based on Graph Attention Networks for IRS-Assisted Satellite IoT Communications
## 3 Proposed RBF-GAT Framework
### RBF-GAT Architecture  
Our network consists of multiple GATs layers and multiple FC layers, as illustrated in Figure 2. First, for the raw feature \(a_{k}\) obtained from the scenario, we need to map such vectors into a higher-dimensional space by a GAT layer, since the raw low-dimension feature contains less network topological information. The input to the GAT layer is a set of node features, \(\mathbf{a}=\{a_{1},a_{2},\cdots,a_{K}\},a_{k}\in\mathbb{R}^{F}\), where \(F\) is the dimension of raw features in each user. To transform \(a_{k}\) into a higher-level feature space of \(F^{\prime}\) dimension, a shared weight matrix, \(\mathbf{W}\in\mathbb{R}^{F^{\prime}\times F}\), is applied to perform a linear transformation. We implement a shared self-attention mechanism \(\text{Atten}(\cdot,\cdot)\) to calculate the attention coefficients of the user and its adjacent users:  
\[e_{ij}=\text{Atten}(\mathbf{W}a_{i},\mathbf{W}a_{j}),\text{ Atten}:\mathbb{R}^{F}\times\mathbb{R}^{F^{\prime}}\rightarrow\mathbb{R} \tag{10}\]  
Note that to indicate the topological information of the network, we computed the attention coefficients only when the distance between user \(i\) and user \(j\) was within certain threshold. For easy comparison, a softmax function is applied to normalize the coefficients across different adjacent users, and the final normalized coefficients \(\alpha_{ij}\) are obtained as:  
\[\alpha_{ij}=\text{softmax}(e_{ij})=\frac{\exp(e_{ij})}{\sum_{j\in l_{i}}\exp( e_{ij})} \tag{11}\]  
Figure 2: The architecture of the proposed RBF-GAT. where \(l_{i}\) is the set of adjacent users including itself in the current neighbourhood scope of the \(i\)-th user. Then, these coefficients are used to calculate a linear combination of the features to produce the output features for the current network user:  
\[a_{k}^{\prime}=\sigma\left(\sum_{j\in l_{k}}\alpha_{kj}\mathbf{W}a_{j}\right) \tag{12}\]  
where \(\sigma(\cdot)\) represents a nonlinear activation function and \(a_{k}^{\prime}\in\mathbb{R}^{F^{\prime}}\) is the output vector of the single-head attention mechanism. To make the self-attention learning process more stable, a multi-head attention mechanism is used in this paper, which can be regarded as multiple single-head attentions executed independently in parallel, and taking the average as the output, can be represented by:  
\[a_{k}^{\prime}=\sigma\left(\frac{1}{H}\sum_{h=1}^{H}\sum_{j\in l_{k}}\alpha_{ kj}^{h}\mathbf{W}^{h}a_{j}\right) \tag{13}\]  
where \(H\) is the number of attention heads, \(\mathbf{W}^{h}\) represents the shared weight matrix of the \(h\)-th attention head. Then, we concatenate the received pilot \(p_{k}\) and the output features \(a_{k}^{\prime}\) as the composite features of user \(k\) and denote them as \(c_{k}\), which is a \((2 ML+F^{\prime})\) dimensional vector because all received pilots are decomposed into real and imaginary parts. \[c_{k} =[(p_{k})^{\text{T}},(a_{k}^{\prime})^{\text{T}}]^{\text{T}} \tag{14}\]  
Significantly, \(c_{k}\) contains rich information about both the instantaneous CSI and network topology structure, so we use it as the input to the composite neural network. After \(c_{k}\) pass through the GAT-2 layer, \(D\) FC layers and a normalization layer, the final output can be mapped directly to the precoding matrix of the satellite and the phase shift of the IRS. We denote \(c_{k}^{0}\) as the output of the second GAT layer, which is also the input of the first FC layer. According to Equation (13), \(c_{k}^{0}\) can be expressed as:  
\[c_{k}^{0}=\sigma\left(\frac{1}{H}\sum_{h=1}^{H}\sum_{j\in l_{k}}\alpha_{kj}^{ h}\mathbf{W}_{1}{}^{h}c_{k}\right) \tag{15}\]  
where \(\alpha_{kj}^{th}\) and \(\mathbf{W}_{1}{}^{h}\in\mathbb{R}^{F^{\prime}\times(2 ML+F^{\prime})}\) are the normalized attention coefficients and the shared weight matrix of the \(h\)-th multihead attentions, respectively.