tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.24k stars 1.09k forks source link

Feature Request: Serialization/deserialization for Distribution class objects #1494

Open jcalifornia opened 2 years ago

jcalifornia commented 2 years ago

From here: https://groups.google.com/a/tensorflow.org/g/tfprobability/c/_9EuU3FnErY/m/cpNQENy6AQAJ

1) Re: saving models: I think it'd be both advantageous and straightforward for us to implement setstate and getstate in Distributions, Bijectors, and DeferredTensor.

For Distributions I'm currently converting all tf.Tensor objects to numpy on getstate and then calling in setstate

variable.assign(
                    tf.cast(value, self.dtype)
                )

Don't know if you guys have a better way of doing this.

reinvantveer commented 2 years ago

:+1: I'd love to use the PixelCNN distribution from tfp but unfortunately it's not usable for me at the moment for lack of a model saving implementation. I don't have a fleet of GPUs at my disposal so I do model selection on a few hyperparameters and retrain the most promising one. But that requires me to save my models...