當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。