Skip to content

Commit

Permalink
Fix bug in Biject.inverse_log_det_jacobian when no event_ndims specif…
Browse files Browse the repository at this point in the history
…ied.

PiperOrigin-RevId: 369272955
  • Loading branch information
jburnim authored and tensorflower-gardener committed Apr 19, 2021
1 parent 1aee21d commit 008f362
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tensorflow_probability/python/bijectors/bijector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ def _call_inverse_log_det_jacobian(self, y, event_ndims, name, **kwargs):
allow_packing=True)

if event_ndims is None:
event_ndims = self.forward_min_event_ndims
event_ndims = self.inverse_min_event_ndims

reduce_shape, assertions = ldj_reduction_shape(
nest.map_structure(ps.shape, y),
Expand Down
8 changes: 8 additions & 0 deletions tensorflow_probability/python/bijectors/bijector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,14 @@ def testNoReductionWhenEventNdimsIsOmitted(self):
np.sum(-np.log(x), axis=-1),
self.evaluate(bij.inverse_log_det_jacobian(x)))

def testInverseWithEventDimsOmitted(self):
bij = tfb.Split(2)

self.assertAllEqual(
0.0,
self.evaluate(bij.inverse_log_det_jacobian(
[tf.ones((3, 4, 5)), tf.ones((3, 4, 5))])))

def testReduceEventNdimsForwardRaiseError(self):
x = [[[1., 2.], [3., 4.]]]
bij = ExpOnlyJacobian(forward_min_event_ndims=1)
Expand Down

0 comments on commit 008f362

Please sign in to comment.