# A Stock Prediction Method Based on Heterogeneous Bidirectional LSTM
## 2 Related Work
### BiLSTM (Bidirectional LSTM) Network  
The core of the BiLSTM architecture lies in utilizing two LSTM layers to process the input sequence in both forward and backward directions, enabling bidirectional information flow. This design allows the model to simultaneously capture historical and future information within the sequence. In non-financial data domains, scholars ([PERSON], [PERSON], [PERSON], & [PERSON], 2014 [20]; [PERSON], [PERSON], & [PERSON], 2013 [21]; [PERSON] & [PERSON], 2005 [22]; [PERSON] & [PERSON], 1997 [23]; [PERSON], [PERSON], & [PERSON], 2019 [24]) have found that its performance surpasses that of LSTM. Later, [PERSON] et al. discovered that the characteristics of the BiLSTM model are more suitable for nonlinear data, such as stock prices, compared to LSTM models. Figure 2 illustrates the structure of the BiLSTM framework, and since forward propagation is divided into front and back directions, we write the front direction as a positive direction and the back direction as a negative direction. In this way, we can distinguish between the reverse direction of forward propagation and the concept of backpropagation. Figure 1: LSTM unit structure. Compared to the LSTM, the structure of the BiLSTM is more complex. In an LSTM unit, there are 12 internal parameters involved in backpropagation updates: \(W_{x}\), \(W_{h}\). and \(b\).. However, for the BiLSTM, the parameters include not only \(W_{x}\), \(W_{h}\). and \(b\). in the positive direction but also \(W_{x}\), \(W_{h}\). and \(b\). in the negative direction, making a total of 24 parameters. For clarity, the parameters of the positive unit are denoted as \(\overrightarrow{W_{x}}\), \(\overrightarrow{W_{h}}\). and \(\overrightarrow{b}\)., and the parameters of the negative unit are denoted as \(\overleftarrow{W_{x}}\), \(\overleftarrow{W_{h}}\). and \(\overleftarrow{b}\).. The forward propagation calculations of the BiLSTM are also divided into two parts: the positive-direction LSTM and the negative-direction LSTM. The calculation formulas for the forward LSTM are (7)-(12). \[\overrightarrow{f_{t}}=\sigma(\overrightarrow{W_{xf}}\cdot x_{t}+ \overrightarrow{W_{hf}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{f}}) \tag{7}\] \[\overrightarrow{i_{t}}=\sigma(\overrightarrow{W_{xi}}\cdot x_{t}+ \overrightarrow{W_{hi}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{i}})\] (8) \[\overrightarrow{c_{t}}=tanh(\overrightarrow{W_{xc}}\cdot x_{t}+ \overrightarrow{W_{hc}}\odot\overrightarrow{h_{t-1}}+\overrightarrow{b_{c }})\] (9) \[\overrightarrow{c_{t}}=\overrightarrow{f_{t}}\odot\overrightarrow {c_{t-1}}+\overrightarrow{i_{t}}\odot\overrightarrow{c_{t}}\] (10) \[\overrightarrow{o_{t}}=\sigma(\overrightarrow{W_{xo}}\cdot x_{t}+ \overrightarrow{W_{ho}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{o}})\] (11) \[\overrightarrow{h_{t}}=\overrightarrow{o_{t}}\odot tanh( \overrightarrow{c_{t}}) \tag{12}\]  
The calculation formulas for the negative direction LSTM are (13)-(18):  
\[\overleftarrow{f_{t}}=\sigma(\overleftarrow{W_{xf}}\cdot x_{t}+ \overleftarrow{W_{hf}}\cdot\overleftarrow{h_{t+1}}+\overleftarrow{b_{f}}) \tag{13}\] \[\overleftarrow{i_{t}}=\sigma(\overleftarrow{W_{xi}}\cdot x_{t}+ \overleftarrow{W_{hi}}\cdot\overleftarrow{h_{t+1}}+\overleftarrow{b_{i}})\] (14) \[\overleftarrow{c_{t}}=tanh(\overleftarrow{W_{xc}}\cdot x_{t}+ \overleftarrow{W_{hc}}\odot\overleftarrow{h_{t+1}}+\overleftarrow{b_{c}}) \tag{15}\]  
\[\overrightarrow{f_{t}}=\sigma(\overrightarrow{W_{xf}}\cdot x_{t}+ \overrightarrow{W_{hf}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{f}}) \tag{7}\]0 BiLSTM structure diagram.