probability
probability copied to clipboard
copy.deepcopy TransformedDistribution fails
import tensorflow_probability as tfp
import copy
tfd =tfp.distributions
tfb = tfp.bijectors
log_normal = tfd.TransformedDistribution(
distribution=tfd.Normal(loc=0., scale=1.),
bijector=tfb.Exp(),
name='LogNormalTransformedDistribution')
copy.deepcopy(log_normal)
The above raises TypeError: missing a required argument: 'distribution'.
Versions: tensorflow-probability==0.17.0, tensorflow==2.9.1.
can you use log_normal.copy()?
actually, this isn't a deep copy. it will reuse the parameters passed to the log_normal constructor. maybe it will suffice for your use case, though.
Hi, thanks. The log_normal is an attribute of a class instance that need to be deep copied. A workaround may be using log_normal.copy() and writing a custom deepcopy method.
But any chance we can directly make a deepcopy of a TransformedDistribution instance? In 0.15.0 I was able to do that.