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 testBijectorForwardInverseWithHingeSoftnessEventDimsZero(self): with self.test_session(): bijector = Softplus(hinge_softness=1.5) x = 2 * rng.randn(2, 10) y = 1.5 * self._softplus(x / 1.5) self.assertAllClose(y, bijector.forward(x).eval()) self.assertAllClose(x, bijector.inverse(y).eval())
def testBijectorForwardInverseWithHingeSoftnessEventDimsZero(self): with self.test_session(): bijector = Softplus(event_ndims=0, hinge_softness=1.5) x = 2 * rng.randn(2, 10) y = 1.5 * self._softplus(x / 1.5) self.assertAllClose(y, bijector.forward(x).eval()) self.assertAllClose(x, bijector.inverse(y).eval())
def testBijectorForwardInverseEventDimsOne(self): with self.test_session(): bijector = Softplus() self.assertEqual("softplus", bijector.name) x = 2 * rng.randn(2, 10) y = self._softplus(x) self.assertAllClose(y, bijector.forward(x).eval()) self.assertAllClose(x, bijector.inverse(y).eval())
def testBijectorForwardInverseEventDimsOne(self): with self.test_session(): bijector = Softplus(event_ndims=1) self.assertEqual("softplus", bijector.name) x = 2 * rng.randn(2, 10) y = self._softplus(x) self.assertAllClose(y, bijector.forward(x).eval()) self.assertAllClose(x, bijector.inverse(y).eval())
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()