Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python 3.6.0 (default, Jan 13 2017, 20:56:47)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> import tensorflow_probability as tfp
>>> dist1 = tfp.distributions.Beta(tf.ones([1]), tf.ones([1]))
>>> dist2 = tfp.distributions.TransformedDistribution(distribution=dist1, bijector=tfp.bijectors.Affine(shift=tf.ones([1])))
>>> dist2.log_prob(tf.zeros([1]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/distribution.py", line 739, in log_prob
return self._call_log_prob(value, name)
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/distribution.py", line 724, in _call_log_prob
return self._log_prob(value, **kwargs)
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/transformed_distribution.py", line 421, in _log_prob
ildj = self.bijector.inverse_log_det_jacobian(y, event_ndims=event_ndims)
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/bijector_impl.py", line 885, in inverse_log_det_jacobian
return self._call_inverse_log_det_jacobian(y, event_ndims, name)
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/bijector_impl.py", line 826, in _call_inverse_log_det_jacobian
event_ndims=event_ndims)):
File "/nail/home/krall/pg/katamari/virtualenv_run/lib/python3.6/site-packages/tensorflow/python/ops/distributions/bijector_impl.py", line 1071, in _check_valid_event_ndims
event_ndims_, min_event_ndims))
ValueError: event_ndims (0) must be larger than min_event_ndims (1)
>>> dist1.batch_shape
TensorShape([Dimension(1)])
>>> dist2.batch_shape
TensorShape([Dimension(1)])
>>> dist1.event_shape
TensorShape([])
>>> dist2.event_shape
TensorShape([])
>>> dist1.log_prob(tf.zeros([1]))
<tf.Tensor 'Beta_2/log_prob/sub_3:0' shape=(1,) dtype=float32>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment