# A Stock Prediction Method Based on Heterogeneous Bidirectional LSTM
## 3 Methodology Proposal
### Structure and Forward Propagation Algorithm of He-BiLSTM  
The structure diagram of He-BiLSTM is shown in Figure 3:  
Figure 3: He-BiLSTM structure diagram. The He-BiLSTM consists of two parts, the variant LSTM and the BiLSTM, which is constructed on the basis of the V-LSTM (Variant LSTM) model. The V-LSTM unit adds a new forget gate internally, which is aimed at the long-term memory \(c_{t}\). Since in the traditional LSTM unit, the information in \(c_{t}\) is not required much in the gating mechanism, it may lead to excessive noise information affecting the unit's ability to process information during the transmission process. Therefore, selectively forgetting information in the long-term memory \(c_{t}\) and retaining useful information can improve the performance of the LSTM unit. On the other hand, for the traditional LSTM unit, many researchers have proven that reasonably simplifying the gating mechanism of the LSTM does not affect the performance of the LSTM. Instead, the simplified structure will reduce the parameters that need to be learned inside the unit, thereby improving the unit's information processing efficiency. For the overall model structure, it can improve the model's running speed while ensuring accuracy. Based on the above two factors, the V-LSTM was designed. In [26], experiments also show that the V-LSTM unit effectively improved some of the problems of the classical LSTM unit, and to a certain extent, improved the model's robustness, accuracy, and generalization performance. The BiLSTM integrates the structures of LSTM in two directions, establishing relationships between units. Therefore, in the BiLSTM, the advantages and disadvantages of the LSTM are both magnified. The disadvantage of the traditional LSTM, which is the inefficiency in processing information that leads to slower model operation, is even more pronounced in the BiLSTM. Based on this situation, considering the improvement of the traditional BiLSTM, the V-LSTM is seamlessly embedded into the BiLSTM to design a He-BiLSTM, thereby enhancing the overall performance of the BiLSTM. Here, the forward propagation formula of He-BiLSTM is as follows:  
\[\overrightarrow{f_{t}}=\sigma(\overrightarrow{W_{xf}}\cdot x_{t}+ \overrightarrow{W_{hf}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{ b_{f}}) \tag{20}\]  
\[\overrightarrow{g_{t}}=\sigma(\overrightarrow{W_{cg}}\odot \overrightarrow{c_{t-1}}) \tag{21}\]  
\[\overrightarrow{i_{t}}=(1-\overrightarrow{f_{t}})\odot \overrightarrow{g_{t}} \tag{22}\]  
\[\overrightarrow{c_{t}}=tanh(\overrightarrow{W_{xc}}\cdot x_{t}+ \overrightarrow{W_{hc}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{c }}) \tag{23}\]  
\[\overrightarrow{c_{t}}=\overrightarrow{f_{t}}\odot \overrightarrow{c_{t-1}}+\overrightarrow{i_{t}}\odot \overrightarrow{c_{t}} \tag{24}\]  
\[\overrightarrow{o_{t}}=\sigma(\overrightarrow{W_{xo}}\cdot x_{t}+ \overrightarrow{W_{ho}}\cdot\overrightarrow{h_{t-1}}+\overrightarrow{b_{o }}) \tag{25}\]  
\[\overrightarrow{h_{t}}=\overrightarrow{o_{t}}\odot tanh(\overrightarrow{c_{t }}) \tag{26}\]  
\[\overleftarrow{f_{t}}=\sigma(\overleftarrow{W_{xf}}\cdot x_{t}+ \overleftarrow{W_{hf}}\cdot\overleftarrow{h_{t+1}}+\overleftarrow{b_{f}}) \tag{27}\]  
Figure 3:0  
Figure 3:1  
Figure 3:2  
Figure 3:3  
Figure 3:4  
Figure 3:5After obtaining \(\overrightarrow{h_{\tau}}\) and \(\overleftarrow{h_{0}}\) at time \(\tau\), compute their dot product using Formula (34) to obtain \(h_{\tau}\) as the final result. Figure 3:6  
After computing \(h_{\tau}\), pass it through a fully connected layer to compute the predicted value \(\hat{y}\), using Formula (35), as follows:  
Figure 3:7  
The loss function here is computed using mean squared error (MSE), denoted as \(E\), with the following calculation formula:  
Figure 3:8  
The formula for calculating the total error (total loss) is  
Figure 3:9