Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anadiedrichs/ec29d4d5c415baa6e6927cbd198940b2 to your computer and use it in GitHub Desktop.
Save anadiedrichs/ec29d4d5c415baa6e6927cbd198940b2 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpeg729
Copy link

jpeg729 commented Oct 2, 2017

I'll start by saying what I understand...
Your LSTM reads in 36 values of a single sensor in chronological order, and it produces a vector containing 18 values that will hopefully correspond to the next 18 values of the same sensor.
If you wanted to predict just the value 18 steps ahead, you would need to do b = dataset[i + look_back + time_step,0] in create_dataset and the output_dim of the Dense layer would need to be 1 rather than T.

The problem I see is that the green lines are out of alignment. The following line of code seems pretty bizarre to me.
testPredictPlot[len(trainPredict)+(look_back*2)+1:len(dataset)-look_back+1, 0] = testPredict[:,0]

Firstly, testPredict[:,0] takes the first value of each output vector, which corresponds to the 1 step ahead predictions, not the T step ahead predictions - for that you would need testPredict[:,T-1]
Secondly, I don't understand why you add (look_back*2) and I suspect that is why the the green line is shifted out of alignment.

You probably need something like the following testPredictPlot[train_size+look_back:len(dataset), 0] = testPredict[:,0]

@anadiedrichs
Copy link
Author

anadiedrichs commented Oct 4, 2017

I'll start by saying what I understand...
Your LSTM reads in 36 values of a single sensor in chronological order, and it produces a vector containing 18 values that will hopefully correspond to the next 18 values of the same sensor.

That's ok, it's the main issue in this notebook.

If you wanted to predict just the value 18 steps ahead, you would need to do b = dataset[i + look_back + time_step,0] in create_dataset and the output_dim of the Dense layer would need to be 1 rather than T.

Ok, thanks for the comment. That's what I need to understand :-)

The problem I see is that the green lines are out of alignment. The following line of code seems pretty bizarre to me.
testPredictPlot[len(trainPredict)+(look_back*2)+1:len(dataset)-look_back+1, 0] = testPredict[:,0]

Firstly, testPredict[:,0] takes the first value of each output vector, which corresponds to the 1 step ahead predictions, not the T step ahead predictions - for that you would need testPredict[:,T-1]
Secondly, I don't understand why you add (look_back*2) and I suspect that is why the the green line is shifted out of alignment.

You probably need something like the following testPredictPlot[train_size+look_back:len(dataset), 0] = testPredict[:,0]

Yes, I've also noticed. I was looking for a way to analyze the error.

I think I get it and I improve the example --> https://gist.github.com/anadiedrichs/f847659d5570938f5f300efb16f81ece

Thanks a lot for your comments!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment