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()
示例#2
0
    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())
示例#3
0
  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())
示例#4
0
    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())
示例#5
0
  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())
示例#6
0
 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()