Пример #1
0
 def testScalarCongruency(self):
     with self.test_session():
         bijector = bijectors.Square(validate_args=True)
         assert_scalar_congruency(bijector,
                                  lower_x=1e-3,
                                  upper_x=1.5,
                                  rtol=0.05)
Пример #2
0
 def testBijectorScalar(self):
     with self.test_session():
         bijector = bijectors.Square(validate_args=True)
         self.assertEqual("square", bijector.name)
         x = [[[1., 5], [2, 1]], [[np.sqrt(2.), 3], [np.sqrt(8.), 1]]]
         y = np.square(x)
         ildj = -np.log(2.) - np.log(x)
         self.assertAllClose(y, bijector.forward(x).eval())
         self.assertAllClose(x, bijector.inverse(y).eval())
         self.assertAllClose(ildj,
                             bijector.inverse_log_det_jacobian(y).eval(),
                             atol=0.,
                             rtol=1e-7)
         self.assertAllClose(-bijector.inverse_log_det_jacobian(y).eval(),
                             bijector.forward_log_det_jacobian(x).eval(),
                             atol=0.,
                             rtol=1e-7)