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

New error message when building statespace_graph #318

Closed
rklees opened this issue Mar 26, 2024 · 11 comments · Fixed by #326
Closed

New error message when building statespace_graph #318

rklees opened this issue Mar 26, 2024 · 11 comments · Fixed by #326

Comments

@rklees
Copy link

rklees commented Mar 26, 2024

I installed the latest version of pymc-experimental and get an error message pointing to

ssm_model.build_statespace_graph(data['meas'], mode="JAX")

The error message is

TypeError: Cannot convert Type Scalar(float64, shape=()) (of Variable sigma_SA_cycle) into Type Vector(float64, shape=(1,)). You can try to manually convert sigma_SA_cycle into a Vector(float64, shape=(1,)).

It refers to the pytensor variable

sigma_SA_cycle = pm.Gamma("sigma_SA_cycle", alpha=2, beta=5)

which is defined in pm.model()

I have installed pytensor version 2.18.6.

Any idea of how to fix this?

@jessegrabowski
Copy link
Member

Looks like a bug related to the refactor a did a few months back. I'll have a look today. Thanks for flagging this.

@rklees
Copy link
Author

rklees commented Mar 27, 2024 via email

@rklees
Copy link
Author

rklees commented Apr 5, 2024

Has this issue been solved in version .18 ??

@jessegrabowski
Copy link
Member

jessegrabowski commented Apr 5, 2024

No, but I'm working on patching it, plus updates to the example notebooks to reflect the changes to expected shapes and dims. I'll push a PR this weekend.

In the meantime you will have to give a singleton shape (via the shape = (1,)) to the parameters that are raising this error. The error is happening because I missed some parameters when I made the decision to require parameters that are never arrays to be scalars (instead of 1d arrays of a single element). In some cases, theparams_info was updated but the required shape of the parameter was not, so there's a mismatch. You have to go with what the error messages tells you to do for now.

@rklees
Copy link
Author

rklees commented Apr 5, 2024 via email

@jessegrabowski
Copy link
Member

Happy to talk on here, or on the pymc discourse. Whatever is most convenient for you.

@rklees
Copy link
Author

rklees commented Apr 8, 2024

I wonder if someone could send me a link to version 0.0.16 with the sigma_xxx are indeed the disturbance standard deviations and not the disturbance variances. In the original 0.0.16 version, sigma_xxx were in fact disturbance variances (the reason for asking is that both version 0.0.17 and version 0.0.18 do not work because of the bug mentioned in this post.

@jessegrabowski
Copy link
Member

#326 will close this issue, and I'll merge it after the CI runs in about an hour. In the meantime, you can request specific versions by using pip, see here

@rklees
Copy link
Author

rklees commented Apr 9, 2024 via email

@jessegrabowski
Copy link
Member

You can try directly installing #326 if you can't wait for it to be merged. Be aware that it breaks old code, because all singleton parameters now do not expect parameters. For example, the cycle dampening parameter, as well as all sigmas. I updated and re-ran all examples in the structural notebook, so you can check that for guidance.

@rklees
Copy link
Author

rklees commented Apr 9, 2024

I installed from #326 and downgraded to pymc=5.12.0. After that, I could run the Structural Time Series modeling notebook you provided and got the same results. However, running pymc-experimental on a synthetic datasets, which I am using already for months, provides results, which are completely different from those obtained with pymc-experimental version 0.0.16. For instance, HDI intervals for the posterior predictive, are completely unrealistic, i.e., orders of magnitude too large.

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 a pull request may close this issue.

2 participants