https://github.com/nixtla logo
p

Phil

07/31/2023, 4:44 PM
Hi All, I'm trying to follow the tutorial for Hierarchical Forecast using the HINT class. https://nixtla.github.io/neuralforecast/examples/hierarchicalnetworks.html I am getting an error running this step:
Copy code
nf.fit(df=Y_train_df, val_size=12)
The final error message is:
Copy code
File ~/Documents/pyTorch/pytorch/lib/python3.9/site-packages/neuralforecast/common/_base_windows.py:460, in BaseWindows.training_step(self, batch, batch_idx)
    458     print("insample_y", torch.isnan(insample_y).sum())
    459     print("outsample_y", torch.isnan(outsample_y).sum())
--> 460     print("output", torch.isnan(output).sum())
    461     raise Exception("Loss is NaN, training stopped.")
    463 self.log("train_loss", loss, prog_bar=True, on_epoch=True)

TypeError: isnan(): argument 'input' (position 1) must be Tensor, not tuple
I am running this tutorial on a MacBook Pro 13.5 (22G74) with python version 3.9. Any idea what is going on?
m

Mark

07/31/2023, 4:54 PM
what model are you using for cls_model
can you show me the code for your HINT class?
p

Phil

07/31/2023, 4:55 PM
Sure. I am following the tutorial here line by line. https://nixtla.github.io/neuralforecast/examples/hierarchicalnetworks.html
Copy code
# Horizon and quantiles
level = np.arange(0, 100, 2)
qs = [[50-lv/2, 50+lv/2] if lv!=0 else [50] for lv in level]
quantiles = np.sort(np.concatenate(qs)/100)

# HINT := BaseNetwork + Distribution + Reconciliation
nhits = NHITS(h=horizon,
              input_size=24,
              loss=GMM(n_components=10, quantiles=quantiles),
              hist_exog_list=['month'],
              max_steps=2000,
              early_stop_patience_steps=10,
              val_check_steps=50,
              scaler_type='robust',
              learning_rate=1e-3,
              valid_loss=sCRPS(quantiles=quantiles))

model = HINT(h=horizon, S=S_df.values,
             model=nhits,  reconciliation='BottomUp')
m

Mark

07/31/2023, 4:58 PM
you're using the dataset used int he example?
p

Phil

07/31/2023, 4:58 PM
yes
Screenshot 2023-07-31 at 9.59.32 AM.png
m

Mark

07/31/2023, 5:00 PM
one sec, running my notebook
p

Phil

07/31/2023, 5:00 PM
Thank you
m

Mark

07/31/2023, 5:04 PM
sorry, i dont know... I'm using my own dataset but it works for me =/
similar layout
p

Phil

07/31/2023, 5:06 PM
Could it be a version problem? By similar layout, do you mean you are running it on the same specs? MacOS, etc...
m

Mark

07/31/2023, 5:06 PM
no i meant dataframe layout is similar. Maybe? I'm on databricks
torch does have a specific version for mac iirc, not sure if that's the issue
p

Phil

07/31/2023, 5:08 PM
I'll try to see if I can run it on Linux... I might have more luck there. Is it possible for you to check if it works with the toy example in the tutorial on databricks
for my own sanity 😅
m

Mark

07/31/2023, 5:08 PM
sure
p

Phil

07/31/2023, 5:08 PM
Thanks Mark! Much appreciated!
m

Mark

07/31/2023, 5:29 PM
how long does it take to fail for you? running 7 minutes sof ar
p

Phil

07/31/2023, 5:29 PM
Oh immediately
m

Mark

07/31/2023, 5:29 PM
😬
yeah, def something with your environment i guess
i was thinking about buying a macbook air, good thing i didnt i guess 😉
🤣 1
p

Phil

07/31/2023, 5:30 PM
Ok I'm installing what I need on my linux VM. Will see if it works there.
👍 1
3 Views