本文整理匯總了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)