Skip to content

'tuple' object has no attribute 'items' in models #1255

@pjbhaumik

Description

@pjbhaumik
  • PyTorch-Forecasting version: 0.10.3
  • PyTorch version: 1.10.2+cpu
  • Python version: 3.8
  • Operating System: jupyterlab notebook

Expected behavior

I executed code Baseline().predict(val_dataloader) in order to get a baseline model and expected to get result baseline predictions

Actual behavior

However, result was
image

pytorch lightning returns a tuple from get_init_args(), so it won't have .items() attribute

Code to reproduce the problem

training = TimeSeriesDataSet(
df[lambda x: x.time_idx <= training_cutoff],
time_idx="time_idx",
target="NPD_LTR_nps",
group_ids=["Label"],
min_encoder_length=max_encoder_length // 2, # keep encoder length long (as it is in the validation set)
max_encoder_length=max_encoder_length,
min_prediction_length=1,
max_prediction_length=max_prediction_length,
static_categoricals=["Label"],
time_varying_known_reals=["time_idx"],
time_varying_unknown_reals= df.drop(columns = ['time_idx', 'Label', 'FLT_LEG_SCHD_DPRT_LDT']).columns.to_list(),
add_relative_time_idx=True,
add_target_scales=True,
add_encoder_length=True,
)

validation = TimeSeriesDataSet.from_dataset(training, df, predict=True, stop_randomization=True)

batch_size = 128 # set this between 32 to 128
train_dataloader = training.to_dataloader(train=True, batch_size=batch_size, num_workers=0)
val_dataloader = validation.to_dataloader(train=False, batch_size=batch_size * 10, num_workers=0)

actuals = torch.cat([y for x, (y, weight) in iter(val_dataloader)])
baseline_predictions = Baseline().predict(val_dataloader)
(actuals - baseline_predictions).abs().mean().item()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions