Search code examples
machine-learningparametersdeep-learninglstmactivation-function

LSTM Predictions


I'm working on a LSTM model, I found some examples and I was confused about the output. Here, I'm trying to predict the next 24 hours, should I put 1 or 24 on the Dense layer? is this section correct ? I've been following this video

reg = Sequential()
reg.add(LSTM(units = 5, activation='relu', input_shape=(24,1)))
reg.add(Dense(24)) #Predicting the next 24h

Thank you.


Solution

  • A dense layer of 1, means you will get one output. So if you are predicting the next hour, you use 1 dense layer. However, keep in mind that if you want to predict the next 24 hours there are two ways to do that. You can iteratively predict 1 hour 24 times by feeding your new prediction into your next time sequence. Or you can predict 24 hours all at once by using a dense layer with 24 outputs.

    Example

    [1,2,3,4,5] is my sequence and I want to predict the 10th value.

    I can predict the 6th value. Then shift my next time sequence so I end up with [2,3,4,5,6]. And keep doing that to predict the 7th, 8th, 9th, and 10th,

    Alternatively, I can use [1,2,3,4,5] to try and predict [6,7,8,9,10] in one step.