jdb78 / pytorch-forecasting

Time series forecasting with PyTorch
https://pytorch-forecasting.readthedocs.io/
MIT License
3.85k stars 609 forks source link

How to change the stride length of the lookback window #563

Closed veds12 closed 3 years ago

veds12 commented 3 years ago

How can I change the slide length of the lookback window? It is one by default, i.e., if my time series is 1, 2, 3, 4, 5, 6, 7, 8, 9 with a lookback window of length of 5 and a prediction horizon of length 2, the sampled encodings will be 1, 2, 3, 4, 5 , 2, 3, 4, 5, 6 and 3, 4, 5, 6, 7. However, I want to change the length of each slide s.t. the lookback window moves ahead with a stride of 2. So, the new sampled encoding will be 1, 2, 3, 4, 5 and 3, 4, 5, 6, 7.

I went through the API of TimeSeriesDataSet.to_dataloader() but could find any option / flag to change the stride size.

veds12 commented 3 years ago

Solved in #229

korosig commented 2 years ago

Have you solved this issue?

veds12 commented 2 years ago

Yes. @korosig please see this: https://github.com/jdb78/pytorch-forecasting/issues/229#issuecomment-753603424 You can define a new batch sampler class which inherits from TimeSynchronousBatchSampler and redefine the __iter__ method with the desired stride length

korosig commented 2 years ago

Yes. @korosig please see this: #229 (comment) You can define a new batch sampler class which inherits from TimeSynchronousBatchSampler and redefine the __iter__ method with the desired stride length

Do you have a version with this modification somewhere? Github repo or Google colab?

blacksnail789521 commented 2 years ago

Just a reminder that it's TimeSynchronizedBatchSampler instead of TimeSynchronousBatchSampler. It took me some time digging into the doc, so I hope this info would help someone save some time.