ptrblck:

In the posted code snippet I’ve reduced the length of the Dataset by the window so that only “full” windows would be returned. I think this would also work for you


I tried doing that by replacing the sentence
        return len(np.asarray(self.X))

with
        return len(self.X) - self.seq

but this error comes if I do that:
  File "/home/lauram/Desktop/RNN_TIMESEQ.py", line 108, in <module>
    for idx, (i, j) in enumerate(loader):

  File "/home/lauram/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()

  File "/home/lauram/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

  File "/home/lauram/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/lauram/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/lauram/Desktop/RNN_TIMESEQ.py", line 57, in __getitem__
    data[:self.__len__()-i] = self.X[i:]

RuntimeError: The expanded size of the tensor (1) must match the existing size (3) at non-singleton dimension 0.  Target sizes: [1, 10].  Tensor sizes: [3, 10]