当前位置: 首页>>代码示例>>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;未经允许,请勿转载。