Error when running Probabilistic Time Series Forecasting

Probabilistic Time Series Forecasting

The following code gave me an error

# perform forward pass
outputs = model(
    past_values=batch["past_values"],
    past_time_features=batch["past_time_features"],
    past_observed_mask=batch["past_observed_mask"],
    static_categorical_features=batch["static_categorical_features"]
    if config.num_static_categorical_features > 0
    else None,
    static_real_features=batch["static_real_features"]
    if config.num_static_real_features > 0
    else None,
    future_values=batch["future_values"],
    future_time_features=batch["future_time_features"],
    future_observed_mask=batch["future_observed_mask"],
    output_hidden_states=True,
)

=====================================================

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[40], line 2
      1 # perform forward pass
----> 2 outputs = model(
      3     past_values=batch["past_values"],
      4     past_time_features=batch["past_time_features"],
      5     past_observed_mask=batch["past_observed_mask"],
      6     static_categorical_features=batch["static_categorical_features"]
      7     if config.num_static_categorical_features > 0
      8     else None,
      9     static_real_features=batch["static_real_features"]
     10     if config.num_static_real_features > 0
     11     else None,
     12     future_values=batch["future_values"],
     13     future_time_features=batch["future_time_features"],
     14     future_observed_mask=batch["future_observed_mask"],
     15     output_hidden_states=True,
     16 )

File ~\anaconda3\lib\site-packages\torch\nn\modules\module.py:1130, in Module._call_impl(self, *input, **kwargs)
   1126 # If we don't have any hooks, we want to skip the rest of the logic in
   1127 # this function, and just call forward.
   1128 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1129         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1130     return forward_call(*input, **kwargs)
   1131 # Do not call functions when jit is used
   1132 full_backward_hooks, non_full_backward_hooks = [], []

File ~\anaconda3\lib\site-packages\transformers\models\time_series_transformer\modeling_time_series_transformer.py:1813, in TimeSeriesTransformerForPrediction.forward(self, past_values, past_time_features, past_observed_mask, static_categorical_features, static_real_features, future_values, future_time_features, future_observed_mask, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, output_hidden_states, output_attentions, use_cache, return_dict)
   1810 if future_values is not None:
   1811     use_cache = False
-> 1813 outputs = self.model(
   1814     past_values=past_values,
   1815     past_time_features=past_time_features,
   1816     past_observed_mask=past_observed_mask,
   1817     static_categorical_features=static_categorical_features,
   1818     static_real_features=static_real_features,
   1819     future_values=future_values,
   1820     future_time_features=future_time_features,
   1821     decoder_attention_mask=decoder_attention_mask,
   1822     head_mask=head_mask,
   1823     decoder_head_mask=decoder_head_mask,
   1824     cross_attn_head_mask=cross_attn_head_mask,
   1825     encoder_outputs=encoder_outputs,
   1826     past_key_values=past_key_values,
   1827     output_hidden_states=output_hidden_states,
   1828     output_attentions=output_attentions,
   1829     use_cache=use_cache,
   1830     return_dict=return_dict,
   1831 )
   1833 prediction_loss = None
   1834 params = None

File ~\anaconda3\lib\site-packages\torch\nn\modules\module.py:1130, in Module._call_impl(self, *input, **kwargs)
   1126 # If we don't have any hooks, we want to skip the rest of the logic in
   1127 # this function, and just call forward.
   1128 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1129         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1130     return forward_call(*input, **kwargs)
   1131 # Do not call functions when jit is used
   1132 full_backward_hooks, non_full_backward_hooks = [], []

File ~\anaconda3\lib\site-packages\transformers\models\time_series_transformer\modeling_time_series_transformer.py:1626, in TimeSeriesTransformerModel.forward(self, past_values, past_time_features, past_observed_mask, static_categorical_features, static_real_features, future_values, future_time_features, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, output_hidden_states, output_attentions, use_cache, return_dict)
   1623 use_cache = use_cache if use_cache is not None else self.config.use_cache
   1624 return_dict = return_dict if return_dict is not None else self.config.use_return_dict
-> 1626 transformer_inputs, scale, static_feat = self.create_network_inputs(
   1627     past_values=past_values,
   1628     past_time_features=past_time_features,
   1629     past_observed_mask=past_observed_mask,
   1630     static_categorical_features=static_categorical_features,
   1631     static_real_features=static_real_features,
   1632     future_values=future_values,
   1633     future_time_features=future_time_features,
   1634 )
   1636 if encoder_outputs is None:
   1637     enc_input = transformer_inputs[:, : self.config.context_length, ...]

File ~\anaconda3\lib\site-packages\transformers\models\time_series_transformer\modeling_time_series_transformer.py:1535, in TimeSeriesTransformerModel.create_network_inputs(self, past_values, past_time_features, static_categorical_features, static_real_features, past_observed_mask, future_values, future_time_features)
   1533 # static features
   1534 log_scale = scale.log() if self.config.input_size == 1 else scale.squeeze(1).log()
-> 1535 static_feat = torch.cat((embedded_cat, static_real_features, log_scale), dim=1)
   1536 expanded_static_feat = static_feat.unsqueeze(1).expand(-1, time_feat.shape[1], -1)
   1538 # all features

TypeError: expected Tensor as element 1 in argument 0, but got NoneType


My Anaconda has Python version :slight_smile: 
!python --version
Python 3.10.9
‚Äč