Creating an LSTM model is only a matter of adding the LSTM layer instead of the SimpleRNN layer, as follows:
model.add(LSTM(units=4, input_shape=(X_train.shape[1], X_train.shape[2])))
The model structure appears as the following:
_________________________________________________________________ Layer (type) Output Shape Param # ================================================================= lstm_1 (LSTM) (None, 4) 96 _________________________________________________________________ dense_1 (Dense) (None, 1) 5 ================================================================= Total params: 101 Trainable params: 101 Non-trainable params: 0 _________________________________________________________________
The complete code for the LSTM model is provided in...