brendanhasz / probflow

A Python package for building Bayesian models with TensorFlow or PyTorch
http://probflow.readthedocs.io
MIT License
171 stars 17 forks source link

Bayesian update method #20

Closed brendanhasz closed 3 years ago

brendanhasz commented 4 years ago

Add a set_priors_to_posteriors (or perhaps something more elegant... bayesian_update? Just update?) method to pf.models.Model which sets the prior distributions to the current value of the posterior distributions, to allow Bayesian updating / streaming inference / incremental updates.

Should be relatively straightforward I think. :thinking: Can't just do for p in self.parameters: p.prior = p.posterior since that would set it by reference, but will need to make a copy of each parameter's posterior Distribution object and fix the underlying variables at their current values (get constants from variables), then set the prior to that. Maybe add a bayesian_udpate() method to Parameter which does that, then Module's bayesian_update() can just be for p in self.parameters: p.bayesian_update()