## 5 Surrounding-Aware Individual Emotion Prediction Model
### Surrounding Attention Network
Similarly, the decoder current hidden state \(\hat{h}^{*}_{t}\) and the current cell state \(\hat{c}^{*}_{t}\) are computed by using Equation (21) and taking the previous hidden state \(\hat{h}^{*}_{t-1}\), the previous cell state \(\hat{c}^{*}_{t-1}\), and earlier output \(\hat{x}^{*}_{t-1}\) as input data:  
\[\hat{h}^{*}_{t},\hat{c}^{*}_{t}=LSTM(\hat{x}^{*}_{t-1},\hat{h}^{*}_{t-1},\hat{ c}^{*}_{t-1}) \tag{21}\]  
Algorithm 2 shows the calculation process for the surrounding context. Initially, for each neighbor \(\hat{o}_{(n)}\), the fixed-size memory representation \(\hat{C}_{(n)}\) is computed. Subsequently, the memory representations of all the neighbors are concatenated to obtain the surrounding memory representation \(\widetilde{C}\). Then, the surrounding memory representation \(\widetilde{C}\) is weighted by the score vector \(\hat{\beta}\) to obtain the surrounding context \(\hat{\mathbf{a}}\). **Input**: The set of observation series \(\{\hat{\chi}^{\prime}_{(1)},\hat{\chi}^{\prime}_{(2)},\dots,\hat{\chi}^{ \prime}_{(n)}\}\), The set of time interval series \(\{\hat{\Delta T}_{(1)},\hat{\Delta T}_{(2)},\dots,\hat{\Delta T}_{(n)}\}\), Number of time-evolving context vector \(Z\), Dimensionality of the cell states \(D\)  
**Output**: Surrounding context vector \(\hat{\mathbf{a}}\)  
```
1://Encoding phase
2:for each neighbor \(\hat{v}_{(n)}\)do
3: Obtain encoder hidden state \(\hat{h}_{u(n)}\) according to Equation (16);
4: Compute position encoding matrix \(L\) by using Equation (12);
5: Compute score vector \(\hat{\mathbf{a}}\) according to Equation (18);
6:for z from 1 to Z do
7: Compute fixed-size memory representation \(\hat{C}_{z(n)}\) by Equation (17);
8:endfor
9:endfor
10: Concatenate the neighbors' memory and obtain surrounding memory representation \(\widetilde{C}\);
11://Decoding phase
12: Obtain decoder hidden state \(\hat{h}^{*}\) by using Equation (21);
13: Calculate score vector \(\hat{\beta}\) according to Equation (20);
14: Compute surrounding context vector \(\hat{\mathbf{a}}\) by using Equation (19);The typical attention mechanism used in previous approaches generates a new attention context at each decoding step. In this model, instead of accessing the encoder state at each encoder step, the SAEP model only need to obtain the pre-computed fixed-size memory representation during encoding, which leads to a smaller computational complexity. ### Learning and Prediction

The goal of the present work is to use information from online social networks and time-evolving data to predict future individual emotions. Therefore, the surrounding context vector \(\mathbf{a}\) and the time-evolving context vector \(\mathbf{a}\) are concatenated. Then, concatenation \(O\) is sent to the full connection layer and pass through softmax. The implementation can be expressed by Equations (22) and (23), respectively:

\[O=[\mathbf{\hat{a}},\mathbf{a}] \tag{22}\]

\[o^{*}=softmax(OW_{o}) \tag{23}\]

where \(W_{o}\) denotes the weight matrix of the fully connected layer. The output \(o^{*}\) of the softmax layer is the probability distribution of the final individual emotion category, where the individual emotion category with the highest probability is considered as the individual emotion prediction label. Consequently, the total loss \(\mathcal{L}\) is expressed as follows:

\[\mathcal{L}=\sum_{n=1}^{N}[\sum_{d=1}^{D}(o^{d(n)}-o^{*d(n)})^{2}\times m^{(n)}] \tag{24}\]

where \(N\) denotes the number of users in the network, and \(D\) is the dimensionality of the emotion vector. \(o^{d(n)}\) and \(o^{*d(n)}\) are the predicted and actual emotion vector elements, respectively. \(m^{(n)}\) represents the elements of the masking series. In the model training phase, SAEP model keeps track of the latest hidden state and all outputs. The last hidden state of the network as the first hidden state of the decoder. A hybrid input strategy is used to feed the data into the feed encoder to speed up the convergence of the model and reduce overfitting.