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.

FR Return deterministics in AutoGuide.quantiles() by default

See original GitHub issue

Currently, nodes that are wrapped in determinstic are not traced, and obtaining inferences from these nodes must be run through a Predictive object. When a user deliberately creates these deterministics they are signalling that their values are of central interest, so it would be convenient to provide them immediately and not force users to execute additional steps.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fonnesbeckcommented, May 17, 2021

I will try and put together a toy example when I get a chance, but I am using the quantiles method on AutoDiagonalNormal in my particular case. This does not include any deterministics.

0reactions
fritzocommented, May 17, 2021

Thanks @fonnesbeck, that makes sense. No need for an example.

I think we can support deterministic sites via a new .predict_quantiles() method.

class AutoGuide(PyroModule):
    ...
    @torch.no_grad()
    def predict_quantiles(self, quantiles, *args, **kwargs):
        data = self.quantiles(quantiles, *args, **kwargs)
        vectorize = pyro.plate(...)  # as in .quantiles() method
        model = condition(vectorize(self.model), data)
        trace = poutine.trace(model).get_trace(*args, **kwargs)
        return {
            name: site["value"]
            for name, site in trace.nodes.items()
            if site["type"] == "sample"
            if not site_is_subsample(site)
        }

    def predict_median(...):
        # ...similar...

Note there would be a couple difficulties inspecting deterministic sites by default:

  1. Deterministic sites require running not only the guide but the model. While it is easy to vectorize the guide, not all models support vectorization. I think the default should make minimal model assumptions.
  2. Some models have enormous observation statements. In those cases computing simple guide quantiles of latent variables can be much cheaper than running the model to generate additional deterministic statements. Again I think the default behavior should be the cheap minimal guide-side computation.

For these reasons I think this issue deserves a new separate interface.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FR Streaming MCMC interface for big models #2843 - GitHub
This issue proposes a streaming architecture for MCMC on models with ... FR Return deterministics in AutoGuide.quantiles() by default #2848.
Read more >
Source code for numpyro.infer.autoguide
:return: A dict mapping sample site name to an array of quantile values. ... _init_locs[name] with ExitStack() as stack: for frame in ...
Read more >
Pyro Documentation - Read the Docs
Returns a callable which returns a sampled module ... Vectorized plate is similar to torch.arange() in that it yields an array of indices...
Read more >
Quantile() function in R - A brief guide | DigitalOcean
In the below sections, let's see how this quantile() function ... some values and the quantile function will return the percentiles for the ......
Read more >
quantile | ClickHouse Docs
Note that for an empty numeric sequence, quantile will return NaN, but its quantile* variants will return either NaN or a default value...
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