# Issues replicating time series analysis with Transformers

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissues-replicating-time-series-analysis-with-transformers%2F39391%3E%5C
**Category:** Beginners\
**Created:** [May 10, 2023, 10:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissues-replicating-time-series-analysis-with-transformers%2F39391 "2023-05-10T10:38:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evasahlholdt](https://avatars.discourse-cdn.com/v4/letter/e/46a35a/32.png) [@evasahlholdt](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fevasahlholdt)%5C
**Post date:** [May 10, 2023, 10:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissues-replicating-time-series-analysis-with-transformers%2F39391%2F1 "2023-05-10T10:38:27Z")

</div>

I am trying to replicate one-to-one the univariate time series analysis using the vanilla Transformer provided in this notebook:

> <https://github.com/huggingface/notebooks/blob/main/examples/time-series-transformers.ipynb>

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?

---

<div class="post-metadata">

**Author:** ![evasahlholdt](https://avatars.discourse-cdn.com/v4/letter/e/46a35a/32.png) [@evasahlholdt](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fevasahlholdt)%5C
**Post date:** [May 10, 2023, 8:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissues-replicating-time-series-analysis-with-transformers%2F39391%2F2 "2023-05-10T20:23:32Z")

</div>

I found the error for any other user who might run into this issue:  
Follow the documentation on [Installation](https://huggingface.co/docs/transformers/installation) and remember to brew install cmake and pkg-config when running on an M1 😄
