def _test(a, scale=1): val_true = stats.gamma.entropy(a, scale=scale) _assert_eq(gamma.entropy(a, scale), val_true) _assert_eq(gamma.entropy(tf.constant(a), tf.constant(scale)), val_true) _assert_eq(gamma.entropy(tf.constant([a]), tf.constant(scale)), val_true) _assert_eq(gamma.entropy(tf.constant(a), tf.constant([scale])), val_true) _assert_eq(gamma.entropy(tf.constant([a]), tf.constant([scale])), val_true)
def _test_entropy(a, scale=1): val_true = stats.gamma.entropy(a, scale=scale) _assert_eq(gamma.entropy(a, scale), val_true) _assert_eq(gamma.entropy(tf.constant(a), tf.constant(scale)), val_true) _assert_eq(gamma.entropy(tf.constant([a]), tf.constant(scale)), val_true) _assert_eq(gamma.entropy(tf.constant(a), tf.constant([scale])), val_true) _assert_eq(gamma.entropy(tf.constant([a]), tf.constant([scale])), val_true)
def _test(self, a, scale=1): val_true = gamma_entropy_vec(a, scale=scale) with self.test_session(): self.assertAllClose(gamma.entropy(a, scale).eval(), val_true) self.assertAllClose( gamma.entropy(tf.constant(a), tf.constant(scale)).eval(), val_true)
def _test(self, alpha, beta): val_true = gamma_entropy_vec(alpha, scale=1.0 / beta) with self.test_session(): self.assertAllClose(gamma.entropy(alpha, beta).eval(), val_true, atol=1e-4) self.assertAllClose(gamma.entropy(tf.constant(alpha), tf.constant(beta)).eval(), val_true, atol=1e-4)
def _test(self, a, scale=1): val_true = gamma_entropy_vec(a, scale=scale) with self.test_session(): self.assertAllClose(gamma.entropy(a, scale).eval(), val_true) self.assertAllClose(gamma.entropy(tf.constant(a), tf.constant(scale)).eval(), val_true)
def _test(self, alpha, beta): val_true = gamma_entropy_vec(alpha, scale=1.0 / beta) with self.test_session(): self.assertAllClose(gamma.entropy(alpha=alpha, beta=beta).eval(), val_true, atol=1e-4)