We create a Stacked LSTM model by stacking multiple hidden LSTM layers, one on top of another. These LSTM layers usually require a 3 dimensional input and LSTMs by default will produce a 2 dimensional output as an interpretation from the end of the sequence. This code is written for Univariate time series prediction, on the framework of Keras and Tensorflow.
I studied about this from https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/ Credits to all sources.