Skip to content

[BUG] Nhits weight argument fix in TimeSeriesDataSet #1432

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

manitadayon
Copy link

@manitadayon manitadayon commented Nov 6, 2023

Adding a weight argument to TimeSeriesDataSet will cause the trainer to throw an error for NhiTS because of a dimension mismatch in dimension 1.
This is because of unsqueeze operation and it is not solely because of missing values (the error will happen even when there is no missing values).
To fix this we can remove the unsqueeze(-1) and multiply the losses and weight directly.
(Ignore the first few commits as they are for NHitS encode-decoder length which is already merged to main)
This is the commit: (**Remove Unsqueeze operation to solve the mismatch operation)

I confirm this by running the same NhiTS model with weight operation set:

Issues:
#1431
#1040

NhiTS covariate fix
NHiTS covariate fix
NhiTS covariate Change
NHitS Covariate fix unit test
NHiTS covariate change test
Remove Additional property line
…into Nhits_weight_support

This is to add a support for weight argument in case of NhiTS model
@manitadayon manitadayon marked this pull request as draft November 6, 2023 03:44
@manitadayon manitadayon marked this pull request as ready for review November 6, 2023 03:44
@jobs-git
Copy link
Contributor

jobs-git commented Jun 7, 2025

Any update?

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test that ensures the bug is fixed.

The changes to conftest also seem to override an already existing fixture - is that intentional?

FYI @jobs-git, this PR is 2 years old, feel free to finalize it (branch off the PR)

@fkiraly fkiraly changed the title Nhits weight argument fix in TimeSeriesDataSet [BUG] Nhits weight argument fix in TimeSeriesDataSet Jun 8, 2025
@@ -199,6 +199,50 @@ def dataloaders_with_different_encoder_decoder_length(data_with_covariates):
)


@pytest.fixture(scope="session")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a copy-paste duplication so I will remove it.

@fkiraly
Copy link
Collaborator

fkiraly commented Jun 8, 2025

I am going through the issues and realize no one has posted a full example that we could use in testing.

Could one of you post a full MRE https://stackoverflow.com/help/minimal-reproducible-example

@manitadayon, @LuigiDarkSimeone, @fnavruzov, @RonanFR, @FrancescoFondaco, @QijiaShao, @terbed

Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (main@4ba4ff5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/metrics/point.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1432   +/-   ##
=======================================
  Coverage        ?   85.59%           
=======================================
  Files           ?       68           
  Lines           ?     6597           
  Branches        ?        0           
=======================================
  Hits            ?     5647           
  Misses          ?      950           
  Partials        ?        0           
Flag Coverage Δ
cpu 85.59% <0.00%> (?)
pytest 85.59% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants