-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError on variable Validation Batch Sizes in TemporalFusionTransformer Tutorial #1509
Comments
I was able to recreate your problem. I changed Let me know if this works for you. |
Thanks! This solves the error. This seems to be a major bug as it should appear at almost every scenario where you use multiple validation batches, right? |
I have not spent a lot of time making predictions using the val_dataloader and I just kept the defaults from the tutorial, maybe this is why it has not been encountered before. I haven't had this issue when using |
Hi @nejox |
hi @fazaki, I didn't really fix that error in my case. For some tests I applied the patch from pull #1511 manually, but in the end I switched to Darts. |
Oh, I see, darts was my backup plan indeed.
|
Expected Behavior
I executed the TemporalFusionTransformer tutorial code to forecast demand on the Tutorial Dataset. I expected the model to train without issues and validate across multiple batches.
Actual Behavior
The tutorial's batch size configuration results in only one validation batch, thereby initially masking the error. When the validation DataLoader splits the dataset into multiple batches, with the last batch containing fewer samples than the specified batch size, I encountered a
RuntimeError
related to tensor size mismatch. Attempting to setdrop_last=True
did not resolve the issue because this setting is overridden when the mode is set to "PREDICTING" as seen here in the PyTorch Lightning codebase.It appears to me that in this case, the concatenation dimension may be incorrectly specified here in the PyTorch Forecasting codebase.
Manually forcing
drop_last=True
to stay (or all batches having the same size) led to a mismatch in the dimensions ofpredict()
'soutput
andy
attributes, further indicating the issue likely resides in the specified dimension for concatenation.Code to reproduce the problem
The issue is reproduced in this Colab notebook.
Snippet of it setting the batch size:
leads to
The text was updated successfully, but these errors were encountered: