예제 #1
0
    def testBijectorBounds(self):
        bijector = Softsign(validate_args=True)
        with self.assertRaisesOpError("greater than -1"):
            self.evaluate(bijector.inverse(-3.))
        with self.assertRaisesOpError("greater than -1"):
            self.evaluate(bijector.inverse_log_det_jacobian(-3.,
                                                            event_ndims=0))

        with self.assertRaisesOpError("less than 1"):
            self.evaluate(bijector.inverse(3.))
        with self.assertRaisesOpError("less than 1"):
            self.evaluate(bijector.inverse_log_det_jacobian(3., event_ndims=0))
예제 #2
0
 def testBijectorLogDetJacobianEventDimsOne(self):
     bijector = Softsign(validate_args=True)
     y = self._rng.rand(2, 10)
     ildj_before = self._softsign_ildj_before_reduction(y)
     ildj = np.sum(ildj_before, axis=1)
     self.assertAllClose(
         ildj,
         self.evaluate(bijector.inverse_log_det_jacobian(y, event_ndims=1)))
예제 #3
0
    def testBijectorLogDetJacobianEventDimsZero(self):
        bijector = Softsign(validate_args=True)
        y = self._rng.rand(2, 10)
        # No reduction needed if event_dims = 0.
        ildj = self._softsign_ildj_before_reduction(y)

        self.assertAllClose(
            ildj,
            self.evaluate(bijector.inverse_log_det_jacobian(y, event_ndims=0)))