def _test_logpdf_scalar(x, a=0.5, b=0.5):
    xtf = tf.constant(x)
    val_true = stats.gamma.logpdf(x, a, scale=b)
    _assert_eq(gamma.logpdf(xtf, tf.constant(a), tf.constant(b)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([a]), tf.constant(b)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant(a), tf.constant([b])), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([a]), tf.constant([b])), val_true)
def _test(x, a, scale=1):
    xtf = tf.constant(x)
    val_true = stats.gamma.logpdf(x, a, scale=scale)
    _assert_eq(gamma.logpdf(xtf, tf.constant(a), tf.constant(scale)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([a]), tf.constant(scale)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant(a), tf.constant([scale])), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([a]), tf.constant([scale])), val_true)
def test_logpdf_1d():
    x = [0.5]
    xtf = tf.constant([0.5])
    val_true = stats.gamma.logpdf(x, 0.5, scale=0.5)
    _assert_eq(gamma.logpdf(xtf, tf.constant(0.5), tf.constant(0.5)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([0.5]), tf.constant(0.5)), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant(0.5), tf.constant([0.5])), val_true)
    _assert_eq(gamma.logpdf(xtf, tf.constant([0.5]), tf.constant([0.5])), val_true)
 def _test(self, x, a, scale=1):
     xtf = tf.constant(x)
     val_true = stats.gamma.logpdf(x, a, scale=scale)
     with self.test_session():
         self.assertAllClose(gamma.logpdf(xtf, tf.constant(a), tf.constant(scale)).eval(), val_true)
Beispiel #5
0
 def _test(self, x, alpha, beta):
   val_true = stats.gamma.logpdf(x, alpha, scale=1.0 / beta)
   with self.test_session():
     self.assertAllClose(gamma.logpdf(x, alpha=alpha, beta=beta).eval(),
                         val_true)