sktime / pytorch-forecasting

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

KeyError in TemporalFusionTransformer on logging of interpretations #821

Open BernhardGlueck opened 2 years ago

BernhardGlueck commented 2 years ago

Expected:

I tried doing some very light experimation with covid case forcasting. I replicated the TemporalFusionTransformer tutorial, without much change.

Actual: However this crashes in log_interpretation in TemporalFusionTransformer due to "outputs" being empty and as such ["interpretation"] results in a key error.

Here is my dataset configuration:

{'time_idx': 'time_idx', 'target': 'new_cases', 'group_ids': ['iso_code'], 'weight': None, 'max_encoder_length': 10, 'min_encoder_length': 10, 'min_prediction_idx': 1, 'min_prediction_length': 10, 'max_prediction_length': 10, 'static_categoricals': [], 'static_reals': [], 'time_varying_known_categoricals': [], 'time_varying_known_reals': [], 'time_varying_unknown_categoricals': [], 'time_varying_unknown_reals': ['new_cases'], 'variable_groups': {}, 'constant_fill_strategy': {}, 'allow_missing_timesteps': True, 'lags': {}, 'add_relative_time_idx': False, 'add_target_scales': False, 'add_encoder_length': False, 'target_normalizer': GroupNormalizer(), 'categorical_encoders': {'__group_id__iso_code': NaNLabelEncoder(), 'iso_code': NaNLabelEncoder()}, 'scalers': {}, 'randomize_length': None, 'predict_mode': False}

Anything i can check to make sure this is not my fault ?

brianslingshot commented 2 years ago

I had encountered the same issue. The exception went away when I added time_idx to time_varying_known_reals. It appears that time_varying_known_reals can't be empty.