本文整理汇总了Python中official.utils.logs.hooks_helper.get_train_hooks方法的典型用法代码示例。如果您正苦于以下问题:Python hooks_helper.get_train_hooks方法的具体用法?Python hooks_helper.get_train_hooks怎么用?Python hooks_helper.get_train_hooks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类official.utils.logs.hooks_helper
的用法示例。
在下文中一共展示了hooks_helper.get_train_hooks方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log_and_get_hooks
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def log_and_get_hooks(eval_batch_size):
"""Convenience function for hook and logger creation."""
# Create hooks that log information about the training and metric values
train_hooks = hooks_helper.get_train_hooks(
FLAGS.hooks,
model_dir=FLAGS.model_dir,
batch_size=FLAGS.batch_size, # for ExamplesPerSecondHook
tensors_to_log={"cross_entropy": "cross_entropy"}
)
run_params = {
"batch_size": FLAGS.batch_size,
"eval_batch_size": eval_batch_size,
"number_factors": FLAGS.num_factors,
"hr_threshold": FLAGS.hr_threshold,
"train_epochs": FLAGS.train_epochs,
}
benchmark_logger = logger.get_benchmark_logger()
benchmark_logger.log_run_info(
model_name="recommendation",
dataset_name=FLAGS.dataset,
run_params=run_params,
test_id=FLAGS.benchmark_test_id)
return benchmark_logger, train_hooks
示例2: test_raise_in_non_list_names
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def test_raise_in_non_list_names(self):
with self.assertRaises(ValueError):
hooks_helper.get_train_hooks(
'LoggingTensorHook, ProfilerHook', model_dir="", batch_size=256)
示例3: test_raise_in_invalid_names
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def test_raise_in_invalid_names(self):
invalid_names = ['StepCounterHook', 'StopAtStepHook']
with self.assertRaises(ValueError):
hooks_helper.get_train_hooks(invalid_names, model_dir="", batch_size=256)
示例4: validate_train_hook_name
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def validate_train_hook_name(self,
test_hook_name,
expected_hook_name,
**kwargs):
returned_hook = hooks_helper.get_train_hooks(
[test_hook_name], model_dir="", **kwargs)
self.assertEqual(len(returned_hook), 1)
self.assertIsInstance(returned_hook[0], tf.estimator.SessionRunHook)
self.assertEqual(returned_hook[0].__class__.__name__.lower(),
expected_hook_name)
示例5: validate_train_hook_name
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def validate_train_hook_name(self,
test_hook_name,
expected_hook_name,
**kwargs):
returned_hook = hooks_helper.get_train_hooks(
[test_hook_name], model_dir="", **kwargs)
self.assertEqual(len(returned_hook), 1)
self.assertIsInstance(returned_hook[0], tf.train.SessionRunHook)
self.assertEqual(returned_hook[0].__class__.__name__.lower(),
expected_hook_name)
示例6: test_raise_in_non_list_names
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def test_raise_in_non_list_names(self):
with self.assertRaises(ValueError):
hooks_helper.get_train_hooks(
'LoggingTensorHook, ProfilerHook', batch_size=256)
示例7: test_raise_in_invalid_names
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def test_raise_in_invalid_names(self):
invalid_names = ['StepCounterHook', 'StopAtStepHook']
with self.assertRaises(ValueError):
hooks_helper.get_train_hooks(invalid_names, batch_size=256)
示例8: validate_train_hook_name
# 需要导入模块: from official.utils.logs import hooks_helper [as 别名]
# 或者: from official.utils.logs.hooks_helper import get_train_hooks [as 别名]
def validate_train_hook_name(self,
test_hook_name,
expected_hook_name,
**kwargs):
returned_hook = hooks_helper.get_train_hooks([test_hook_name], **kwargs)
self.assertEqual(len(returned_hook), 1)
self.assertIsInstance(returned_hook[0], tf.train.SessionRunHook)
self.assertEqual(returned_hook[0].__class__.__name__.lower(),
expected_hook_name)