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

TimeGrad Notebook version 0.7.0 -> predicts all nans #162

Open
StefanStanisor opened this issue Mar 6, 2024 · 8 comments
Open

TimeGrad Notebook version 0.7.0 -> predicts all nans #162

StefanStanisor opened this issue Mar 6, 2024 · 8 comments

Comments

@StefanStanisor
Copy link

Hello, I am writing my master thesis and while trying to make timegrad work for at least an example, I tried the example in the notebook. I looked at all the other issues people mentioned, but I think I got a new one.

The predictor outputs all nans. This is the code that I am using:

device = torch.device('mps')

dataset = get_dataset("electricity_nips", regenerate=False)
train_grouper = MultivariateGrouper(max_target_dim=min(2000, int(dataset.metadata.feat_static_cat[0].cardinality)))

test_grouper = MultivariateGrouper(num_test_dates=int(len(dataset.test)/len(dataset.train)),
                                   max_target_dim=min(2000, int(dataset.metadata.feat_static_cat[0].cardinality)))

dataset_train = train_grouper(dataset.train)
dataset_test = test_grouper(dataset.test)
scheduler = DEISMultistepScheduler(
    num_train_timesteps=150,
    beta_end=0.1,
)
estimator = TimeGradEstimator(
    input_size=int(dataset.metadata.feat_static_cat[0].cardinality),
    hidden_size=64,
    num_layers=2,
    dropout_rate=0.1,
    lags_seq=[1],
    scheduler=scheduler,
    num_inference_steps=150,
    prediction_length=dataset.metadata.prediction_length,
    context_length=dataset.metadata.prediction_length,
    freq=dataset.metadata.freq,
    scaling="mean",
    trainer_kwargs=dict(max_epochs=1, accelerator="gpu", devices="1"),
)

predictor = estimator.train(dataset_train)

s = time.time()
forecast_it, ts_it = make_evaluation_predictions(dataset=dataset_test,
                                                 predictor=predictor,
                                                 num_samples=100)

forecasts = list(forecast_it)
targets = list(ts_it)
@fbehnia
Copy link

fbehnia commented Mar 7, 2024

I am trying to run the the Time-Grad-Electricity notebook, and from the following Iine I get an error.
line:
dataset_test = test_grouper(dataset.test)

error:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2590,) + inhomogeneous part.

Do you know how I can fix this issue?

@Wjie-Z
Copy link

Wjie-Z commented Mar 26, 2024

I am trying to run the the Time-Grad-Electricity notebook, and from the following Iine I get an error.
line:
dataset_test = test_grouper(dataset.test)

error:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2590,) + inhomogeneous part.
Have you solved it?

@fbehnia
Copy link

fbehnia commented Mar 31, 2024

I am trying to run the the Time-Grad-Electricity notebook, and from the following Iine I get an error. line: dataset_test = test_grouper(dataset.test)

error: ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2590,) + inhomogeneous part. Have you solved it?

I had the same issue I used version 0.7.0 and edit the notebook based on #152

@fbehnia
Copy link

fbehnia commented Mar 31, 2024

Hello, I am writing my master thesis and while trying to make timegrad work for at least an example, I tried the example in the notebook. I looked at all the other issues people mentioned, but I think I got a new one.

The predictor outputs all nans. This is the code that I am using:

device = torch.device('mps')

dataset = get_dataset("electricity_nips", regenerate=False)
train_grouper = MultivariateGrouper(max_target_dim=min(2000, int(dataset.metadata.feat_static_cat[0].cardinality)))

test_grouper = MultivariateGrouper(num_test_dates=int(len(dataset.test)/len(dataset.train)),
                                   max_target_dim=min(2000, int(dataset.metadata.feat_static_cat[0].cardinality)))

dataset_train = train_grouper(dataset.train)
dataset_test = test_grouper(dataset.test)
scheduler = DEISMultistepScheduler(
    num_train_timesteps=150,
    beta_end=0.1,
)
estimator = TimeGradEstimator(
    input_size=int(dataset.metadata.feat_static_cat[0].cardinality),
    hidden_size=64,
    num_layers=2,
    dropout_rate=0.1,
    lags_seq=[1],
    scheduler=scheduler,
    num_inference_steps=150,
    prediction_length=dataset.metadata.prediction_length,
    context_length=dataset.metadata.prediction_length,
    freq=dataset.metadata.freq,
    scaling="mean",
    trainer_kwargs=dict(max_epochs=1, accelerator="gpu", devices="1"),
)

predictor = estimator.train(dataset_train)

s = time.time()
forecast_it, ts_it = make_evaluation_predictions(dataset=dataset_test,
                                                 predictor=predictor,
                                                 num_samples=100)

forecasts = list(forecast_it)
targets = list(ts_it)

I am also getting all NaNs did you solve it?

@2ySong
Copy link

2ySong commented Jun 18, 2024

I also got the all NaNs, I can't solve it.

@jiajinghu19
Copy link

Did anyone solve the all NaN's problem? I also got all the NaNs

@2ySong
Copy link

2ySong commented Jul 10, 2024

you can set the num_inference_steps=149 that will solve the problem.

@jiajinghu19
Copy link

you can set the num_inference_steps=149 that will solve the problem.

Thank you! It worked!

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

No branches or pull requests

5 participants