本文整理汇总了Python中official.utils.misc.model_helpers.past_stop_threshold方法的典型用法代码示例。如果您正苦于以下问题:Python model_helpers.past_stop_threshold方法的具体用法?Python model_helpers.past_stop_threshold怎么用?Python model_helpers.past_stop_threshold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类official.utils.misc.model_helpers
的用法示例。
在下文中一共展示了model_helpers.past_stop_threshold方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_past_stop_threshold_not_number
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import past_stop_threshold [as 别名]
def test_past_stop_threshold_not_number(self):
"""Tests for error conditions."""
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold("str", 1)
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold("str", tf.constant(5))
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold("str", "another")
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold(0, None)
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold(0.7, "str")
with self.assertRaises(ValueError):
model_helpers.past_stop_threshold(tf.constant(4), None)
示例2: test_past_stop_threshold
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import past_stop_threshold [as 别名]
def test_past_stop_threshold(self):
"""Tests for normal operating conditions."""
self.assertTrue(model_helpers.past_stop_threshold(0.54, 1))
self.assertTrue(model_helpers.past_stop_threshold(54, 100))
self.assertFalse(model_helpers.past_stop_threshold(0.54, 0.1))
self.assertFalse(model_helpers.past_stop_threshold(-0.54, -1.5))
self.assertTrue(model_helpers.past_stop_threshold(-0.54, 0))
self.assertTrue(model_helpers.past_stop_threshold(0, 0))
self.assertTrue(model_helpers.past_stop_threshold(0.54, 0.54))
示例3: test_past_stop_threshold_none_false
# 需要导入模块: from official.utils.misc import model_helpers [as 别名]
# 或者: from official.utils.misc.model_helpers import past_stop_threshold [as 别名]
def test_past_stop_threshold_none_false(self):
"""Tests that check None returns false."""
self.assertFalse(model_helpers.past_stop_threshold(None, -1.5))
self.assertFalse(model_helpers.past_stop_threshold(None, None))
self.assertFalse(model_helpers.past_stop_threshold(None, 1.5))
# Zero should be okay, though.
self.assertTrue(model_helpers.past_stop_threshold(0, 1.5))