# Social Media Opinion Analysis Model Based on Fusion of Text and Structural Features
## 3 Proposed HGAT Model
### Encoding Layer  
At this layer, a graph embedding method based on heterogeneous networks is used to extract and fuse contextual feature information from the feedback. In the dataset of this paper, the polarity of sentiment expressed in contextual feedback is often opposite, i.e., responses to feedback under the \"Huawei\" topic news often have conflicting relationships with one another. Unfortunately, most graph embedding algorithms, such as GCN and GAT, often merge neighboring node features based on the assumption of node homogeneity, which is contrary to the purpose of the present paper. Social media opinion prediction requires an algorithm that can perform graph embeddings on strongly heterogeneous graphs and can aggregate features from neighboring nodes with strong heterogeneity in order to update the node's own feature vector. The H\({}_{2}\)GCN model is a graph embedding vector representation method for heterogeneous networks, which re-designs the feature fusion strategy for highly heterogeneous networks. The H\({}_{2}\)GCN model first aggregates the features of the neighboring nodes of the target node and combines the calculation results with the target node's own feature vector to update the target node's feature. In this paper, the HGAT model is modified based on the H\({}_{2}\)GCN model, and the node representation vector obtained by the input layer is multiplied by an initial trainable weight matrix \(W_{emb}\in\mathbb{R}^{(128\times\rho)}\) as the initial vector feature \(r_{v}^{0}\) of the node. \[r_{v}^{0}=relu(F_{fc}(X)*W_{emb}) \tag{1}\]  
\(relu\) represents the Rectified Linear Unit activation function, \(F_{fc}\) represents the fully connected function, \(\rho\) represents the specified output vector dimension of the hidden layer in HGAT, and \(X\) represents the matrix of input vector representations in the encoding layer. In addition, in this paper, an attention mechanism is introduced to aggregate the characteristics of the neighboring nodes for the representation vector \(r_{v}^{(k)}\) of the node \(v\). The attention mechanism calculates the attention coefficients of the neighboring nodes of the target node and updates the feature vector of the target node based on the feature vectors of the neighboring nodes. A key point of the attention mechanism is to determine the influence of the surrounding nodes on the attention coefficients of the current node. To calculate the attention coefficients, the correlation coefficient between the target node and its neighboring nodes needs to be calculated. The input feature matrix \(h=\left\{\vec{h_{0}},\vec{h_{1}},\vec{h_{2}},\cdots,\vec{h_{n}}\right\}\), \(\vec{h_{i}}\in\mathbb{R}^{F}\), then the calculation formula of the correlation coefficient \(e_{i,j}\) between node \(i\) and node \(j\) is as follows:  
\[e_{i,j}=LeakyReLu(\vec{a}(W\vec{h_{i}}\mid\mid W\vec{h_{j}})) \tag{2}\]  
in the formula, \(W\in\mathbb{R}^{(F^{\prime}\times F)}\) represents the weight matrix, where \(F^{\prime}\) represents the dimension of the specified output features. \(W\) is applied to each node to ensure that each node can perform a self-attention operation to obtain an attention coefficient. The \(||\) symbol represents the defined attention operation function. The vector \(\vec{a}\) in the formula represents a feedforward neural network with a dimension of \(\vec{a}\in\mathbb{R}^{(2\times F^{\prime})}\), and the result calculated by the neural network is non-linearized by the \(LeakyReLU\) function to obtain the correlation coefficient \(e_{i,j}\) between node \(i\) and node \(j\). Based on Equation (3), the attention coefficient between node \(i\) and node \(j\) can be obtained by normalization, denoted as \(\alpha_{(i,j)}\), which is given by:  
\[\alpha_{i,j}=\frac{exp(e_{i,j})}{\sum_{k\in N_{i}}exp(e_{i,k})} \tag{3}\]where \(N_{i}\) represents all neighboring nodes of the target node \(i\). After obtaining the node attention coefficient, the updated feature vector of node \(i\) can be obtained by summing up the weighted features of all its neighboring nodes.