I have trained a NN in Keras with LSTM, so I have been using 3D tensors. Now I want to predict with a dataset and I have to insert a 3D tensor in my NN.
(In my case I used features = 2 and lookback = 2, so input elements in LSTM are (batch_size, lookback, features))
So, imagine this example:
a = np.array([[1, 2],
[3, 4]])
I need to do a_2 = np.reshape(1, 2, 2) to be able to insert it in the LSTM.
But if I have a bigger test dataset, like for instance:
b = np.array([[1, 2],
[3, 4],
[5, 6],
[7, 8],
[9, 10]])
I would need to convert it to a 3D array of this type:
b_2 = np.array([[[1, 2],
[3, 4]],
[[3, 4],
[5, 6]],
[[5, 6],
[7, 8]],
[[7, 8],
[9, 10]]])
so in this case I have predictions for each lookback with the new point. I guess this could be done with a complicated solution using many for loops nested, but I wonder if there is more pythonic way. Thx.