question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

generative_function is broken for models with non-optional args

See original GitHub issue

Given 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:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
elanmartcommented, Mar 31, 2021

@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 😃

1reaction
rloufcommented, Mar 23, 2021

(again, thank you for raising an issue!)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found