Add small test to check hinge_softness != 0 in softplus bijector.

Change: 154773145
This commit is contained in:
A. Unique TensorFlower 2017-05-01 14:59:25 -08:00 committed by TensorFlower Gardener
parent 68c514faa9
commit 8a123f7d1b
2 changed files with 9 additions and 1 deletions

View File

@ -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)

View File

@ -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)