# Prediction of Stock Performance Using Deep Neural Networks
## 3 Deep Neural Network-Based Model for Stock Performance Prediction  
### Long Short-Term Memory Networks  
Long Short-Term Memory networks--usually just called \"LSTMs\"--are a special kind of RNN equipped with a special gating mechanism that controls access to memory cells. Since the introduction of the gates, LSTM and its variant have shown great promise in tackling various sequence modeling tasks in machine learning--e.g., natural language processing, image captioning, and speech recognition. Basically, a LSTM unit consists of an input gate, a forget gate, and an output gate. The architecture of an LSTM unit is shown in Figure 1.  
\begin{table}
\begin{tabular}{l c} \hline \hline
**Strategy** & **Variable Used to Classify Stocks** \\ \hline Constant Threshold-Based Stock Classification & \(\alpha_{\text{C}}=\frac{\text{HP}_{\text{in\_past\_12 weeks}}-\text{CP}}{\text{CP}}\) \\ \hline Ranking-Based Stock Classification & \(\alpha_{\text{R}}=\frac{\text{CP}_{\text{in\_past\_12 weeks}}-\text{CP}}{\text{CP}}\) \\ \hline Constant Threshold-Based Stock Classification & \(\beta_{\text{C}}=\frac{\alpha_{\text{C}}}{\text{STD}\Big{(}\textbf{CP}_{\text{in\_past\_12 weeks}}/\text{CP}\Big{)}}\) \\ \hline Ranking Threshold-Based Stock Classification & \(\beta_{\text{R}}=\frac{\alpha_{\text{R}}}{\text{STD}\Big{(}\textbf{CP}_{\text{in\_past\_12 weeks}} /\text{CP}\Big{)}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Summary of the proposed four strategies for stock classification.  
Suppose that \(\mathbf{x}_{t}\) is the input and \(\mathbf{h}_{t-1}\) is the hidden output from the last time step \(t\)-1, the input gate decides how much of the new information will be added to the cell state \(\mathbf{c}_{t}\), and generates a candidate \(\mathbf{\tilde{c}}_{t}\) by:  
\[\mathbf{i}_{t}=\sigma(\mathbf{W}_{xi}\mathbf{x}_{t}+\mathbf{W}_{hi}\mathbf{h}_ {t-1}+\mathbf{b}_{i}) \tag{5}\]  
\[\mathbf{\tilde{c}}_{t}=\phi(\mathbf{W}_{xx}\mathbf{x}_{t}+\mathbf{W}_{hc} \mathbf{h}_{t-1}+\mathbf{b}_{c}) \tag{6}\]  
where \(\mathbf{i}_{t}\) can be thought of as a knob that the LSTM learns to selectively consider \(\mathbf{\tilde{c}}_{t}\) for the current time step. \(\sigma\) is the logistic sigmoid function and \(\phi\) is _tanh_. Generally, \(\mathbf{W}\) terms denote weight matrices (e.g., \(\mathbf{W}_{xi}\) is the matrix of weights from the input to the input gate), and \(\mathbf{b}\) terms are the bias vectors. The forget gate decides how previous information will be kept in the new time step, and is defined as:  
\[\mathbf{f}_{t}=\sigma\big{(}\mathbf{W}_{xf}\mathbf{x}_{t}+\mathbf{W}_{hf} \mathbf{h}_{t-1}+\mathbf{b}_{f}\big{)} \tag{7}\]  
Then, the cell state \(\mathbf{c}_{t}\) is updated by:  
\[\mathbf{c}_{t}=\mathbf{f}_{t}\odot\mathbf{c}_{t-1}+\mathbf{i}_{t}\odot \mathbf{\tilde{c}}_{t} \tag{8}\]  
where \(\odot\) is the element-wise product of the vectors. Then, the output gate uses the output \(\mathbf{o}_{t}\) to control what is then read from the new cell state \(\mathbf{c}_{t}\) onto the hidden vector \(\mathbf{h}_{t}\) as follows:  
\[\mathbf{o}_{t}=\sigma(\mathbf{W}_{x0}\mathbf{x}_{t}+\mathbf{W}_{ho}\mathbf{h} _{t-1}+\mathbf{b}_{o}) \tag{9}\]  
\[\mathbf{h}_{t}=\mathbf{o}_{t}\odot\phi(\mathbf{c}_{t}) \tag{10}\]  
In this study, the functional LSTM(\(\cdot\),\(\cdot\),\(\cdot\)) is used as shorthand for the LSTM model in Equation (11):  
\[(\mathbf{h}_{t},\mathbf{c}_{t})=\text{LSTM}(\mathbf{x}_{t},\mathbf{h}_{t-1}, \mathbf{c}_{t-1},\mathbf{W},\mathbf{b}) \tag{11}\]  
where \(\mathbf{W}\) and \(\mathbf{b}\) include the weight matrices and bias vectors indicated in Equations (5)-(9). The value of \(\mathbf{W}\) and \(\mathbf{b}\) are determined in the training step.