def testGetLogitsAndProbsProbabilityValidateArgs(self):
p = [0.01, 0.2, 0.5, 0.7, .99]
# Component less than 0.
p2 = [-1, 0.2, 0.5, 0.3, .2]
# Component greater than 1.
p3 = [2, 0.2, 0.5, 0.3, .2]
with self.test_session():
_, prob = distribution_util.get_logits_and_probs(
probs=p, validate_args=True)
prob.eval()
with self.assertRaisesOpError("Condition x >= 0"):
_, prob = distribution_util.get_logits_and_probs(
probs=p2, validate_args=True)
prob.eval()
_, prob = distribution_util.get_logits_and_probs(
probs=p2, validate_args=False)
prob.eval()
with self.assertRaisesOpError("probs has components greater than 1"):
_, prob = distribution_util.get_logits_and_probs(
probs=p3, validate_args=True)
prob.eval()
_, prob = distribution_util.get_logits_and_probs(
probs=p3, validate_args=False)
prob.eval()
distribution_util_test.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录