當前位置: 首頁>>代碼示例>>Python>>正文


Python evaluation._get_or_create_eval_step方法代碼示例

本文整理匯總了Python中tensorflow.python.training.evaluation._get_or_create_eval_step方法的典型用法代碼示例。如果您正苦於以下問題:Python evaluation._get_or_create_eval_step方法的具體用法?Python evaluation._get_or_create_eval_step怎麽用?Python evaluation._get_or_create_eval_step使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.training.evaluation的用法示例。


在下文中一共展示了evaluation._get_or_create_eval_step方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _increase_eval_step_op

# 需要導入模塊: from tensorflow.python.training import evaluation [as 別名]
# 或者: from tensorflow.python.training.evaluation import _get_or_create_eval_step [as 別名]
def _increase_eval_step_op(iterations_per_loop):
  """Returns an op to increase the eval step for TPU evaluation.

  Args:
    iterations_per_loop: Tensor. The number of eval steps running in TPU system
      before returning to CPU host for each `Session.run`.

  Returns:
    An operation
  """
  eval_step = evaluation._get_or_create_eval_step()  # pylint: disable=protected-access
  # Estimator evaluate increases 1 by default. So, we increase the difference.
  return state_ops.assign_add(
      eval_step,
      math_ops.cast(iterations_per_loop - 1, dtype=eval_step.dtype),
      use_locking=True) 
開發者ID:ymcui,項目名稱:Chinese-XLNet,代碼行數:18,代碼來源:tpu_estimator.py

示例2: _increase_eval_step_op

# 需要導入模塊: from tensorflow.python.training import evaluation [as 別名]
# 或者: from tensorflow.python.training.evaluation import _get_or_create_eval_step [as 別名]
def _increase_eval_step_op(iterations_per_loop):
  """Returns an op to increase the eval step for TPU evaluation.

  Args:
    iterations_per_loop: Tensor. The number of eval steps running in TPU
        system before returning to CPU host for each `Session.run`.

  Returns:
    An operation
  """
  eval_step = evaluation._get_or_create_eval_step()  # pylint: disable=protected-access
  # Estimator evaluate increases 1 by default. So, we increase the difference.
  return state_ops.assign_add(
      eval_step,
      math_ops.cast(iterations_per_loop - 1, dtype=eval_step.dtype),
      use_locking=True) 
開發者ID:kimiyoung,項目名稱:transformer-xl,代碼行數:18,代碼來源:tpu_estimator.py

示例3: _increase_eval_step_op

# 需要導入模塊: from tensorflow.python.training import evaluation [as 別名]
# 或者: from tensorflow.python.training.evaluation import _get_or_create_eval_step [as 別名]
def _increase_eval_step_op(iterations_per_loop):
  """Returns an op to increase the eval step for TPU evaluation.

  Args:
    iterations_per_loop: Tensor. The number of eval steps running in TPU system
      before returning to CPU host for each `Session.run`.

  Returns:
    An operation
  """
  eval_step = evaluation._get_or_create_eval_step()  # pylint: disable=protected-access
  # Estimator evaluate increases 1 by default. So, we increase the difference.
  return tf.compat.v1.assign_add(
      eval_step,
      tf.cast(iterations_per_loop - 1, dtype=eval_step.dtype),
      use_locking=True) 
開發者ID:tensorflow,項目名稱:estimator,代碼行數:18,代碼來源:tpu_estimator.py

示例4: _evaluate_build_graph

# 需要導入模塊: from tensorflow.python.training import evaluation [as 別名]
# 或者: from tensorflow.python.training.evaluation import _get_or_create_eval_step [as 別名]
def _evaluate_build_graph(self, input_fn, hooks=None, checkpoint_path=None):
    """Builds the graph and related hooks to run evaluation."""
    tf.compat.v1.random.set_random_seed(self._config.tf_random_seed)
    self._create_and_assert_global_step(tf.compat.v1.get_default_graph())

    if self._eval_distribution:
      (scaffold, evaluation_hooks, input_hooks, update_op, eval_dict) = (
          self._call_model_fn_eval_distributed(input_fn, self.config))
    else:
      (scaffold, evaluation_hooks, input_hooks, update_op, eval_dict) = (
          self._call_model_fn_eval(input_fn, self.config))

    global_step_tensor = tf.compat.v1.train.get_global_step(
        tf.compat.v1.get_default_graph())
    # Call to warm_start has to be after model_fn is called.
    self._maybe_warm_start(checkpoint_path)

    if tf.compat.v1.GraphKeys.GLOBAL_STEP in eval_dict:
      raise ValueError(
          'Metric with name `global_step` is not allowed, because Estimator '
          'already defines a default metric with the same name.')
    eval_dict[tf.compat.v1.GraphKeys.GLOBAL_STEP] = global_step_tensor

    all_hooks = list(input_hooks)
    all_hooks.extend(hooks)
    all_hooks.extend(list(evaluation_hooks or []))
    # New local variables have been added, so update the estimator spec's
    # local init op if it was defined.
    if scaffold and scaffold.local_init_op:
      # Ensure that eval step has been created before updating local init op.
      evaluation._get_or_create_eval_step()  # pylint: disable=protected-access

      scaffold = tf.compat.v1.train.Scaffold(
          local_init_op=tf.group(
              scaffold.local_init_op,
              tf.compat.v1.train.Scaffold.default_local_init_op()),
          copy_from_scaffold=scaffold)

    return scaffold, update_op, eval_dict, all_hooks 
開發者ID:tensorflow,項目名稱:estimator,代碼行數:41,代碼來源:estimator.py


注:本文中的tensorflow.python.training.evaluation._get_or_create_eval_step方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。