当前位置: 首页>>代码示例>>Python>>正文


Python hooks_helper.get_train_hooks方法代码示例

本文整理汇总了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 
开发者ID:IntelAI,项目名称:models,代码行数:26,代码来源:ncf_estimator_main.py

示例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) 
开发者ID:IntelAI,项目名称:models,代码行数:6,代码来源:hooks_helper_test.py

示例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) 
开发者ID:IntelAI,项目名称:models,代码行数:6,代码来源:hooks_helper_test.py

示例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) 
开发者ID:IntelAI,项目名称:models,代码行数:12,代码来源:hooks_helper_test.py

示例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) 
开发者ID:rockyzhengwu,项目名称:nsfw,代码行数:12,代码来源:hooks_helper_test.py

示例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) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:6,代码来源:hooks_helper_test.py

示例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) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:6,代码来源:hooks_helper_test.py

示例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) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:11,代码来源:hooks_helper_test.py


注:本文中的official.utils.logs.hooks_helper.get_train_hooks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。