Hi, I would like to know how to use DNN or CNN to predict multi time steps ahead not only 1 time step prediction.
Increase number of output units in the final layer. Making changes to the dataset is also required for this to work.
Here’s an example:
- Assume data points to have time steps [0, 1, 2, 3, 4, 5, …]
- Say you are interested in predicting 2 steps based on 5 steps of input data.
- Your model will require input shape of (5,) and the number of units of the final layer should be 2
- When preparing the data, the X and y pairs will look like this:
X: [0, 1, 2, 3, 4] y: [5, 6]
X: [1, 2, 3, 4, 5] y: [6, 7]
X: [2, 3, 4, 5, 6] y: [7, 8]
Or have you considered using an RNN?
haha! yes, of course I am using RNN! I am trying to generalize the labs in the Time Series course to multi time step pred. All the course labs are only 1 time step pred.
Thanks Balaji! This is very helpful. I prepared the data as you instructed and got [n,2] model forecast for 2 time steps ahead prediction. But intuitively I don’t understand how the number of units in the final layer determines the number of time steps in y.
Maybe I’m just missing your point, but if an RNN (e.g. doing language translation) outputs a complete sentence, then that’s multiple output timesteps, isn’t it?
For example, in the Dinosaur Name assignment in Week 1 we implement a model that outputs a multicharacter name one timestep at a time.
oh sorry for confusion! You are referring to Deep Learning specialization. Course 5, Week 1, Assignmenet 2 where we built an RNN from scratch.
My question is about Sequences, Time Series and Prediction course https://www.coursera.org/learn/tensorflow-sequences-time-series-and-prediction, in which we use Tensor Flow Keras RNN models. I would like to generalize the labs in this course to multi time step prediction.
Oh, sorry. But maybe it’s not a bad idea to take a look at the DLS C5 material. Later in W2 - W4, there are a number of examples of RNNs built with TF which have multiple step outputs.
From deep learning specialization and TF developer professional notebooks, it should be clear on how to recursively make a 1 step prediction into the future using the most recent window of input data.
My suggested approach of using multiple output units is just a interpretation of the model outputs. As shared in the earlier post, the 0th output can be considered as the prediction for n+1 th timestep & the 1st output can be interpreted as the prediction for n+2 nd timestep. Intention is to use multi-task learning to learn by predicting 2 outputs i.e. timesteps in this case.
Thank you Paulin! I go back to DLS C5 to review the materials again.
Thanks Balaji! That makes sense!
one more questions please: in the case of univariate time series multi step ahead prediction, we can interpret the number of units in the last layer as the number of time steps we are predicting the one variable. What about the case of predicting multi time step for multivariate time series? for example we have 3 time series that we know they are related and we would like to model 3 of them together and predict them together 10 steps ahead. how will our RNN input shape and last layer look like?
@ElhamS unfortunately I am not an expert on this topic yet, but your description makes the situation sound very ‘Bayesian’, or you have a probability update cycle in a chain (though perhaps that is not all there is).
Accordingly I was also recently reading this: Bayesian Neural Networks
Nothing says the intermediate steps are linear in nature.
Since you’ve taken up DLS, we know that input shape of an RNN is (#timesteps, #features per timestep)
. For your problem, the input shape is (# input timesteps, 3).
Based on this information and my earlier post on how to interpret weights differently, please figure out the shape of output layer.