def _test(x, loc=0, scale=1): xtf = tf.constant(x) val_true = stats.uniform.logpdf(x, loc, scale) _assert_eq(uniform.logpdf(xtf, loc, scale), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant(loc), tf.constant(scale)), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant([loc]), tf.constant(scale)), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant(loc), tf.constant([scale])), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant([loc]), tf.constant([scale])), val_true)
def _test(self, x, a, b): xtf = tf.constant(x) val_true = stats.uniform.logpdf(x, a, b - a) with self.test_session(): self.assertAllClose(uniform.logpdf(xtf, a, b).eval(), val_true) self.assertAllClose( uniform.logpdf(xtf, tf.constant(a), tf.constant(b)).eval(), val_true)
def _test_logpdf(x, loc=0, scale=1): xtf = tf.constant(x) val_true = stats.uniform.logpdf(x, loc, scale) _assert_eq(uniform.logpdf(xtf, loc, scale), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant(loc), tf.constant(scale)), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant([loc]), tf.constant(scale)), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant(loc), tf.constant([scale])), val_true) _assert_eq(uniform.logpdf(xtf, tf.constant([loc]), tf.constant([scale])), val_true)
def _test(self, x, loc=0, scale=1): xtf = tf.constant(x) val_true = stats.uniform.logpdf(x, loc, scale) with self.test_session(): self.assertAllClose(uniform.logpdf(xtf, loc, scale).eval(), val_true) self.assertAllClose(uniform.logpdf(xtf, tf.constant(loc), tf.constant(scale)).eval(), val_true)
def _test(self, x, a, b): val_true = stats.uniform.logpdf(x, a, b - a) with self.test_session(): self.assertAllClose(uniform.logpdf(x, a=a, b=b).eval(), val_true)