Skip to content

[numpyro] Add discussions on model functions in numpyro #622

@HumphreyYang

Description

@HumphreyYang

See discussion by @jstac in #569 (comment)

NumPyro uses a functional core with an imperative shell: the function here is just a specification (like writing specification down in sympy), and a stack of effect handlers (dynamic, thread-local) reinterprets each numpyro.sample(...) during execution.

When we call mcmc.run(...), the kernel (e.g., NUTS) builds a pure log-density from the model via these handlers and then does the sampling. So the handlers don’t do sampling per sa; they construct the potential function the sampler needs.

It can be a bit much for readers who just want posterior draws, so I can add a few simple notes next to the first NumPyro code cells in the previous lecture to demystify this a little.

Add discussion in the lecture Non-Conjugate Priors where it is first used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions