nok-halfspace / Transformer-Time-Series-Forecasting

373 stars 102 forks source link

Input and Target Indices #8

Closed Tolga-Karahan closed 2 years ago

Tolga-Karahan commented 2 years ago

Thanks for sharing this inspiring work. When I was inspecting your SensorDataset class I couldn't understand the part you're creating input and target variables. For input this indices are used: [start : start + self.T], and for target this ones: [start + self.T : start + self.T + self.S]. Shouldn't model output next timestamp for each input so for example if input indices start with n. timestamp then target must start with (n+1). timestamp, but I wonder whether it's not the case for your work?

Tolga-Karahan commented 2 years ago

Or the point is getting a subset for training and another subset that immediately follow the training subset for forecasting and for each new idx window is shifted to right?

nok-halfspace commented 2 years ago

Hi, thanks for your comment. As you said, it predicts the window shifted once to the right.

src = _input.permute(1,0,2).double().to(device)[:-1,:,:] 
target = _input.permute(1,0,2).double().to(device)[1:,:,:] # src shifted by 1.
prediction = model(src, device) 
loss = criterion(prediction, target[:,:,0].unsqueeze(-1))