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

sample_posterior_predictive returns the wrong dimension #3343

Closed
FedericoV opened this issue Jan 16, 2019 · 9 comments
Closed

sample_posterior_predictive returns the wrong dimension #3343

FedericoV opened this issue Jan 16, 2019 · 9 comments
Assignees

Comments

@FedericoV
Copy link

If you have questions about a specific use case, or you are not sure whether this is a bug or not, please post it to our discourse channel: https://discourse.pymc.io

Description of your problem

sample_posterior_predictive adds an extra dimension when sampling a multivariate observation

Please provide a minimal, self-contained, and reproducible example.

train_obs = model.observed_RVs[0]
print(train_obs.name, train_obs.eval().shape)

model = eu_forecaster.model_
advi = pm.ADVI(model=model)
approx = advi.fit(10)
trace = approx.sample(10)

posterior = pm.sample_posterior_predictive(trace=trace, model=model)

print(posterior['train_obs'].shape)

Please provide the full traceback.

train_obs (730, 56)
  0%|          | 0/10 [00:00<?, ?it/s]/home/ubuntu/anaconda3/lib/python3.7/site-packages/theano/tensor/subtensor.py:2320: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  out[0][inputs[2:]] = inputs[1]
/home/ubuntu/anaconda3/lib/python3.7/site-packages/theano/tensor/basic.py:6592: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  result[diagonal_slice] = x
/home/ubuntu/anaconda3/lib/python3.7/site-packages/theano/tensor/subtensor.py:2190: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  rval = inputs[0].__getitem__(inputs[1:])
Average Loss = 2.5178e+14: 100%|██████████| 10/10 [00:00<00:00, 120.98it/s]
Finished [100%]: Average Loss = 2.6755e+17
100%|██████████| 10/10 [00:06<00:00,  1.55it/s]
(10, 730, 730, 56)

Please provide any additional information below.
This is something that has only started showing up with the very latest version of PyMC3. I will try downgrading and see if that fixes it. The model still fits fine, and, looking at the parameter distributions, they look reasonable.

Versions and main components

  • PyMC3 Version: 3.6
  • Theano Version: '1.0.2'
  • Python Version: 3.7
  • Operating system:
  • How did you install PyMC3: git clone
@FedericoV
Copy link
Author

I can confirm that if I revert to commit (88acc7c) this does not appear, so it seems like it's a very recent issue.

@lucianopaz
Copy link
Contributor

Could you post your model's code to better understand what distribution causes the error?
The most likely commit that could have introduced this is c73f97d, could you try if you see the same error there?
If yes, we will certainly need your model's code or an equivalent model that also has this error to be able to fix the problem.

@FedericoV
Copy link
Author

The model unfortunately is fairly complicated and built by a class that does a lot of other stuff. I'll try to see if I can do a simpler version that reproduces it: the main thing is the likelihood is a full rank multivariate gaussian.

@lucianopaz
Copy link
Contributor

Does it use a Mixture distribution at some point? Does it encode the covariance with LKJCholeskyCov distribution?

@FedericoV
Copy link
Author

FedericoV commented Jan 17, 2019 via email

@lucianopaz
Copy link
Contributor

Then it may be an issue with the new LKJCholeskyCov.random method. When you post a simplified model that reproduces the problematic behavior, we will be able to start working on a fix

@lucianopaz
Copy link
Contributor

@FedericoV, any luck with getting a minimal model that reproduces the error?

@lucianopaz
Copy link
Contributor

@FedericoV, any update?

@junpenglao
Copy link
Member

Should be fixed, close for now.

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

No branches or pull requests

3 participants