You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EnsemblePosterior.sample(x) checks x only in the posteriors it draws #2195
EnsemblePosterior.sample(x=...) checks x only in the component posteriors that the random draw picks. An ensemble of VI posteriors fit to different observations can therefore return samples for an x that some of its posteriors were never fit to, without an error.
The ensemble first draws a component for each sample, then calls sample() of each drawn component. A VI posterior trained with train(x=x_o) raises when it gets another x, but only if it is drawn:
fits= []
forx_oin (2*ones(1, 2), -2*ones(1, 2)):
vi=VIPosterior(potential_fn, prior, q="gaussian")
vi.train(x=x_o)
fits.append(vi)
ensemble=EnsemblePosterior(fits, weights=[0.99, 0.01])
ensemble.sample((5,), x=2*ones(1, 2)) # returns samples in most draws, raises in a few
The ensemble should raise before it draws whenever one of its posteriors cannot take x, so that the result does not depend on the draw. One way: a method that checks x without sampling, which single-x VI overrides and the ensemble calls for every component.
Activity
test: keep the tests that catch silent regressions, move ensemble tests
test: keep the tests that catch silent regressions, move ensemble tests
fix!: amortized VI sample() and log_prob() take one observation (sbi-…