# Heat Load Forecasting of Marine Diesel Engine Based on Long Short-Term Memory Network
## 2 Prediction Method
### Long Short-Term Memory Network  
LSTM is a neural network proposed by [PERSON] and [PERSON] in 1997 Hochreiter and  
Input Gate: Whether the information is stored in the storage unit is determined by the threshold and denotes it as \(i_{t}\).  
Forget Gate: Whether the information stored in the storage unit at the previous time is stored in the storage unit at the current time is determined by the threshold and denotes it as \(f_{t}\).  
Output Gate: Whether the information in the storage unit at the current moment enters the hidden state \(h_{t}\) is determined by the threshold and denotes it as \(o_{t}\).  
Historical information can be saved, read, updated, and reset by the unit; it is the core of the LSTM unit and is denoted as \(C_{t}\).  
The LSTM neural network at moment t is expressed as follows:  
\[f_{t}=\sigma(W_{f}\cdot[h_{t-1},X_{t}]+b_{f}), \tag{1}\]  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},X_{t}]+b_{i}), \tag{2}\]  
\[o_{t}=\sigma(W_{o}\cdot[h_{t-1},X_{t}]+b_{o}), \tag{3}\]  
\[\widetilde{C}_{t}=\tanh(W_{C}\cdot[h_{t-1},X_{t}]+b_{c}), \tag{4}\]  
\[C_{t}=f_{t}\times C_{t-1}+i_{t}\otimes\widetilde{C}_{t}, \tag{5}\]  
\[h_{t}=o_{t}\times\tanh(C_{t}), \tag{6}\]  
where \(f_{t}\), \(i_{t}\), \(o_{t}\), and \(h_{t}\) are (1), (2), (3), and (6), respectively; \(W_{f}\), \(W_{i}\), \(W_{o}\), and \(W_{C}\) denote the recursive connection weights of the corresponding thresholds; \(\sigma\) is the sigmoid function, which is the same as the \(\tanh\) function for the activation in Equations (7) and (8).  
\[\sigma(x)=\frac{1}{1+e^{-x}}, \tag{7}\]  
\[\tanh(x)=\frac{\sinh(x)}{\cosh(x)}=\frac{e^{x}-e^{-x}}{e^{x}+e^{-x}}, \tag{8}\]  
The state at the previous point in time needs to be discarded, and the content saved to the memory unit is determined by the forgetting gate. The sigmoid function is used to decide whether \(C_{t-1}\) is cumulatively retained or not. Cumulative retention is achieved when the sigmoid function is equal to 1 but is absent when the function is equal to 0.  
The input gate contains the output \(h_{t-1}\) from the previous moment and the input \(X_{t}\) at this time, and the sigmoid function is used to control how much to add to \(C_{t}\). An alternative \(\widetilde{C}_{t}\) is also created and then the \(\tanh\) function can be used to control how much to add to \(\widetilde{C}_{t}\). The two parts are then multiplied to determine the amount of influence \(C_{t}\), and the influence of the forgetting gate is added to obtain the expression for \(C_{t}\).  
The output gate is a sigmoid function that can determine which parts of \(C_{t}\) need to be output to describe the \(o_{t}\) expression. \(C_{t}\) is placed into the \(\tanh\) function to determine the final output \(C_{t}\) and then multiplied with \(o_{t}\) to obtain the final output \(h_{t}\), which signals the end and outputted at each moment are determined and affected by the three thresholds, and they are finally transferred to the state of this moment at the end.  
The prediction results of LSTM model are affected by the learning rate, weights, activation function, step size, and number of batches in the network. For example, convergence failure is caused by learning rate being set too high, while consuming a lot of training time to calculate the optimal value is caused by learning rate being set too low. Problems, such as gradient explosion and disappearance, can occur when the activation function is poorly chosen. Therefore, LSTM prediction model needs to be trained, and appropriate parameters are selected to improve the prediction accuracy.