I’m using an LSTM to predict a time-seres of floats. I’m using a window of 20 prior datapoints (seq_length = 20) and no features (input_dim =1) to predict  the “next” single datapoint. My network seems to be learning properly.
Here’s the observed data vs. predicted with the trained model:

time_series_LSTM.png1280×960 88.6 KB

Here’s a naive implementation of how to predict multiple steps ahead using the trained network:
data = timeseries[-20:] # Last observed data  (20 datapoints)
last_seq = data.reshape(seq_length,1,input_dim) # Batch size of 1, tensor of size (20,1,1)
last_seq = torch.from_numpy(last_seq).float() # pytorch tensor of floats
last_pred = model.forward(Variable(last_seq, requires_grad=False))
last_pred = last_pred.data.numpy()
data = np.append(data, last_pred) # This now contains 21 values, take the last 20 and repeat appropriately.

When I do this the predictions recurrently for the last 20 observations (which at some point include only predicted values) I get:

Figure_1.png1280×960 46.8 KB
 

What is the right way to use a trained LSTM to generate predictions for future timesteps?
Are LSTM the right tool to predict sequences of floats? Will something like seq2seq allow me to predict sequences of floats from sequences of floats?