From 8a123f7d1bca579a1401a10804eb1a45e213d6bc Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 1 May 2017 14:59:25 -0800 Subject: [PATCH] Add small test to check hinge_softness != 0 in softplus bijector. Change: 154773145 --- .../python/kernel_tests/bijectors/softplus_test.py | 6 ++++++ .../distributions/python/ops/bijectors/softplus_impl.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/softplus_test.py b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/softplus_test.py index e8abde40875..214b196b547 100644 --- a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/softplus_test.py +++ b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/softplus_test.py @@ -41,6 +41,12 @@ class SoftplusBijectorTest(test.TestCase): """Inverse log det jacobian, before being reduced.""" return -np.log(1 - np.exp(-y)) + def testHingeSoftnessZeroRaises(self): + with self.test_session(): + bijector = Softplus(event_ndims=0, hinge_softness=0., validate_args=True) + with self.assertRaisesOpError("must be non-zero"): + bijector.forward([1., 1.]).eval() + def testBijectorForwardInverseEventDimsZero(self): with self.test_session(): bijector = Softplus(event_ndims=0) diff --git a/tensorflow/contrib/distributions/python/ops/bijectors/softplus_impl.py b/tensorflow/contrib/distributions/python/ops/bijectors/softplus_impl.py index baa41cfcbde..81957fcf789 100644 --- a/tensorflow/contrib/distributions/python/ops/bijectors/softplus_impl.py +++ b/tensorflow/contrib/distributions/python/ops/bijectors/softplus_impl.py @@ -94,7 +94,9 @@ class Softplus(bijector.Bijector): if validate_args: nonzero_check = check_ops.assert_none_equal( ops.convert_to_tensor( - 0, dtype=self.hinge_softness.dtype), self.hinge_softness) + 0, dtype=self.hinge_softness.dtype), + self.hinge_softness, + message="hinge_softness must be non-zero") self._hinge_softness = control_flow_ops.with_dependencies( [nonzero_check], self.hinge_softness)