Training data shapping

The error tells you that you are trying to index into an array that has 3 dimensions with 4 dimensions.

Looking at the value from your error, it looks exactly like I’d expect to see here. You’ve got one (1) sequence with two (2) features and that sequence has 5635 steps.

You have two features and one label with your current setup. I guess you want to have three features and three labels, such that the features at step t_n+1 are the labels for step t_n.

As you are struggling with the setup, I guess that the easiest way for you to do that would be to just generate the csv file to be exactly like that, i.e. 6 columns, first 3 have the inputs and last 3 have the outputs.

As for using that data to also run prediction:

If you look at the javadoc for rnnTimeStep it says:

So you have to feed it with data that has the expected shape.

Let’s assume that you have managed to set up your data the way I suggested it above (3 input values and 3 output values), then calling .getFeatures on the dataset will already produce an array that has the shape [1, 3, 5635]. If you want to take just the first 90 time steps of it, you can do it like that:

features.get(NDArrayIndex.all(), NDArrayIndex.all(), NDArrayIndex.interval(0, 90))

And it will have the shape [1, 3, 90].

You can then feed it to .rnnTimeStep and you will get outputs for all 90 steps. To now get the next 20 steps, you will need to take the output for just the last step (if you want to be lazy, feed it the last 89 steps first, then the 90th on its own, so you don’t have to do any sub array access) and use it as the input for .rnnTimeStep. You repeat this until you have collected all the 20 steps into the future.