File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/transformers/models/autoformer Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1303,12 +1303,15 @@ def get_lagged_subsequences(
1303
1303
# calculates the indices of the lags by subtracting the shift value from the given lags_sequence
1304
1304
indices = [lag - shift for lag in self .config .lags_sequence ]
1305
1305
1306
- # checks if the maximum lag plus the length of the subsequences exceeds the length of the input sequence
1307
1306
sequence_length = sequence .shape [1 ]
1308
- if max (indices ) + subsequences_length > sequence_length :
1307
+ # We need to check if the sequence is long enough to create the lags
1308
+ min_len_for_lags = max (self .config .lags_sequence ) + subsequences_length
1309
+ if sequence_length < min_len_for_lags :
1309
1310
raise ValueError (
1310
- f"lags cannot go further than history length, found lag { max (indices )} "
1311
- f"while history length is only { sequence_length } "
1311
+ "The length of the 'past_values' tensor is too short for the configured lags. "
1312
+ f"To use lags up to { max (self .config .lags_sequence )} , the input sequence length needs to be at least "
1313
+ f"{ min_len_for_lags } (max_lag + context_length + prediction_length), but it is only "
1314
+ f"{ sequence_length } ."
1312
1315
)
1313
1316
1314
1317
# extracts the lagged subsequences from the input sequence using the calculated indices
You can’t perform that action at this time.
0 commit comments