generative_function is broken for models with non-optional args
See original GitHub issueGiven the model:
@mcx.model
def model(x):
a <~ dist.Normal(0, 1)
return a
This code: https://github.com/rlouf/mcx/blob/master/mcx/model.py#L218-L220
Will generate a function with a signature model_sample_posterior_predictive(rng_key, x, a)
This function will then be called here: https://github.com/rlouf/mcx/blob/master/mcx/model.py#L226-L228
passing *self.trace.chain_values(self.chain_id)
as x
.
The fix is to modify the generative_function.__call__
method to
def __call__(self, rng_key, *args, **kwargs) -> jnp.DeviceArray:
"""Call the model as a generative function."""
posterior_kwd = {k: self.trace[k].reshape(-1) for k in self.trace.keys()}
return self.call_fn(
rng_key, *args, **kwargs, **posterior_kwd,
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Generating migrations with cli · Issue #8810 · typeorm ... - GitHub
Issue Description Expected Behavior Migrations get generated using the cli Actual Behavior I am following the documentation outlined here ...
Read more >R: lme4 News
only=TRUE) now handles models with "non-syntactic" (e.g. space-containing/backtick-delimited) variables in the formula. confint(<merMod>) now works again for ...
Read more >Creating forms from models - Django documentation
Each model field has a corresponding default form field. ... This save() method accepts an optional commit keyword argument, which accepts either True...
Read more >Nixpkgs 22.11 manual - NixOS
Nix expressions describe how to build packages from source and are collected in the nixpkgs repository. Also included in the collection are Nix...
Read more >OMNeT++ - Simulation Manual - Index of - omnetpp.org
Modules communicate with messages that may contain arbitrary data, in addition to usual attributes such as a timestamp. Simple modules typically send ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rlouf thanks a lot! In the meantime I’ve just patched my local version of
mcx
so I can carry on without issues. For #90 I also have a small workaround, so it’s all fine for now 😃(again, thank you for raising an issue!)