I am trying to replicate one-to-one the univariate time series analysis using the vanilla Transformer provided in this notebook:
I am using Jupyter notebook in VS Code, Python 3.10.9 and Jupyter 6.5.4 in a virtual environment.
Everything runs smoothly until the forward pass, where I get the following error (full traceback):
Traceback (most recent call last)
/var/folders/vq/0s913kg97lv155_r9j2g9qxm0000gn/T/ipykernel_63681/2795771002.py:2 in
[Errno 2] No such file or directory:
β/var/folders/vq/0s913kg97lv155_r9j2g9qxm0000gn/T/ipykernel_63681/2795771002.pyβ
/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py:1190 in _call_impl
β 1187 β β # this function, and just call forward. β
β 1188 β β if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o β
β 1189 β β β β or _global_forward_hooks or _global_forward_pre_hooks): β
β β± 1190 β β β return forward_call(*input, **kwargs) β
β 1191 β β # Do not call functions when jit is used β
β 1192 β β full_backward_hooks, non_full_backward_hooks = , β
β 1193 β β if self._backward_hooks or global_backward_hooks: β
β β
β /opt/homebrew/lib/python3.10/site-packages/transformers/models/time_series_transformer/modeling β
β time_series_transformer.py:1813 in forward β
β β
β 1810 β β if future_values is not None: β
β 1811 β β β use_cache = False β
β 1812 β β β
β β± 1813 β β outputs = self.model( β
β 1814 β β β past_values=past_values, β
β 1815 β β β past_time_features=past_time_features, β
β 1816 β β β past_observed_mask=past_observed_mask, β
β β
β /opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py:1190 in _call_impl β
β β
β 1187 β β # this function, and just call forward. β
β 1188 β β if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks o β
β 1189 β β β β or _global_forward_hooks or _global_forward_pre_hooks): β
β β± 1190 β β β return forward_call(*input, **kwargs) β
β 1191 β β # Do not call functions when jit is used β
β 1192 β β full_backward_hooks, non_full_backward_hooks = , β
β 1193 β β if self.backward_hooks or global_backward_hooks: β
β β
β /opt/homebrew/lib/python3.10/site-packages/transformers/models/time_series_transformer/modeling β
β time_series_transformer.py:1626 in forward β
β β
β 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 β
β 1625 β β β
β β± 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, β
β β
β /opt/homebrew/lib/python3.10/site-packages/transformers/models/time_series_transformer/modeling β
β time_series_transformer.py:1535 in create_network_inputs β
β β
β 1532 β β embedded_cat = self.embedder(static_categorical_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], - β
β 1537 β β β
β 1538 β β # all features β
β°βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ―
TypeError: expected Tensor as element 1 in argument 0, but got NoneType
I am fairly new to Transformers (and Python in general) but I suspect the issue lies in relation to the error:
[Errno 2] No such file or directory:
β/var/folders/vq/0s913kg97lv155_r9j2g9qxm0000gn/T/ipykernel_63681/2795771002.pyβ
I checked the directory, and indeed no such file exists. I tried upgrading ipykernel without success. There seems to be no issues loading all required libraries in their newest versions.
Any suggestions as to what the issue might be?