pyro-ppl/pyro

extending Predictive to support sampling by plate name

Offen

#2.783 geöffnet am 16.03.2021

 (5 Kommentare) (1 Reaktion) (0 zugewiesene Personen)Python (981 Forks)batch import
discussionenhancementhelp wanted

Repository-Metriken

Stars
 (8.211 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 10T 19h) (1 gemergte PR in 30 T)

Beschreibung

Following our earlier discussion with @fritzo and @adamgayoso , creating this issue. Would be great if Predictive class can support sampling of all variables in a given plate, automatically pulling all site values in a given plate(plate_name) or all sites not is that plate, including both samples and observed values:

trace = poutine.trace(model).get_trace(*args, **kwargs)  # you'll need to fill in args,kwargs
cell_samples = {
    name: site["value"]
    for name, site in trace.nodes.items()
    if site["type"] == "sample"
    if any(f.name == plate_name for f in site["cond_indep_stack"])
}

This functionality would simplify dealing with local variables within a minibatch plate, by making it easy to do separate predictive calls for the minibatch plate variables and global variables.

Contributor Guide