Skip to content
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

Nhits weight argument fix in TimeSeriesDataSet #1432

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion pytorch_forecasting/metrics/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def update(

# weight samples
if weight is not None:
losses = losses * weight.unsqueeze(-1)
losses = losses * weight

self._update_losses_and_lengths(losses, lengths)

Expand Down
30 changes: 30 additions & 0 deletions tests/test_models/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,36 @@ def make_dataloaders(data_with_covariates, **kwargs):
def multiple_dataloaders_with_covariates(data_with_covariates, request):
return make_dataloaders(data_with_covariates, **request.param)

@pytest.fixture(scope="session")
def dataloaders_with_different_encoder_decoder_length(data_with_covariates):
return make_dataloaders(
data_with_covariates.copy(),
target="target",
time_varying_known_categoricals=["special_days", "month"],
variable_groups=dict(
special_days=[
"easter_day",
"good_friday",
"new_year",
"christmas",
"labor_day",
"independence_day",
"revolution_day_memorial",
"regional_games",
"fifa_u_17_world_cup",
"football_gold_cup",
"beer_capital",
"music_fest",
]
),
time_varying_known_reals=["time_idx", "price_regular", "price_actual", "discount", "discount_in_percent"],
time_varying_unknown_categoricals=[],
time_varying_unknown_reals=["target", "volume", "log_volume", "industry_volume", "soda_volume", "avg_max_temp"],
static_categoricals=["agency"],
add_relative_time_idx=False,
target_normalizer=GroupNormalizer(groups=["agency", "sku"], center=False),
)


@pytest.fixture(scope="session")
def dataloaders_with_different_encoder_decoder_length(data_with_covariates):
Expand Down