## 5 Surrounding-Aware Individual Emotion Prediction Model
### Time-Evolving Attention Network  
An important factor that should be considered for individual emotion prediction is the time-evolving influence, that is, how a user's historical behaviors and individual emotional states can be related to the individual future emotional states. To capture this temporal correlation of users' emotional states, a memory-based attention network is constructed in the proposed model, called time-evolving attention network. Given a user \(v_{t}\), their emotion time series \(X\) is used to extract the observed series \(X^{{}^{\prime}}\) and time interval series \(\Delta T\). In the encoding phase, the goal is to use a T-LSTM network to capture information in an irregular time series. A T-LSTM network is used to encode the information of the user's individual emotional change trend in the form of a T-LSTM  
Figure 6: Illustration of the time-aware long-short term memory (T-LSTM) unit. hidden state, which takes the observed series \(X^{{}^{\prime}}\) and time interval series \(\Delta T\) as input data. The iterative process is expressed by Equation (9). \[h_{u},c_{u}=T-LSTM(x^{{}^{\prime}}_{u},\Delta t_{u},h_{u-1},c_{u-1}) \tag{9}\]  
where \(c_{u}\) and \(h_{u}\) respectively are cell adjusted state and hidden state. Many approaches capture contextual information in a time series. The most popular method is based on the encoder-decoder architecture consisting of two RNNs and an attention mechanism that aligns the target to the source tokens [45]. The attention mechanism used in these methods calculates the attention context by analyzing the encoder and decoder at each step. However, such calculations are expensive. [PERSON] et al. [46] present a memory-based attention approach, and they demonstrate the efficiency of their model in experiments. In this paper, a memory-based attention approach is used to efficiently compute the time-evolving context. During encoding, a fixed-size memory representation \(C\in\mathbb{R}^{Z\times D}\) is computed, where \(Z\) is a hyperparameter that indicates the number of time-evolving context vectors in the SAEP model, and \(D\) is the dimensionality of the cell states. A score vector \(\alpha_{u}\in\mathbb{R}^{Z}\) is predicted at each encoding time step \(u\), and the memory representation \(C\) in Equation (10) as a linear combination of the encoder states weighted by a score vector \(\alpha_{u}\). \[C_{z}=\sum_{u=0}^{|U|}\alpha_{uz}h_{u} \tag{10}\]  
\[\alpha_{uz}=softmax(h_{u}W_{a}\circ l_{u}) \tag{11}\]  
where \(W_{a}\) is a parameter matrix in \(\mathbb{R}^{Z\times D}\). \(l_{u}\) represents position encoding, which ensures that the context information learned is different. More specifically, because \(C_{i}\) is not necessarily different from \(C_{i\
eq i}\), the predictions of the context vectors may be symmetric. To enable the model to learn different context information, the position encodings enforce the first few context vectors \(C_{1}\), \(C_{2},\dots\) to focus on the start of the series, and the last few context vectors \(\dots,C_{Z-1},C_{Z}\) to focus on the end of the series. To obtain the position encoding \(l_{u}\), it is necessary to compute a constant matrix \(L\). Mathematically, each element of \(L\) can be expressed as shown in Equation (12). \[L_{zu}=(1-\frac{z}{Z})(1-\frac{u}{U})+\frac{z}{Z}\frac{u}{U} \tag{12}\]  
where \(z\in\{1,2,\dots,Z\}\) denotes the context vector index, and \(U\) is the maximum series length across all emotion time series. In the proposed SAEP model, a standard LSTM network is used as the decoder, which can employ memory representations to reconstruct the original emotion time series. Similar to the encoding phase, a score vector \(\beta\in\mathbb{R}^{Z}\) is computed at each decoding step. Then, the time-evolving context vector \(\mathbf{a}\) is finally obtained by using Equation (13), which is a linear combination of memory representations weighted by a score vector \(\beta\) (Equation (14)).