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


Python session_run_hook.SessionRunArgs方法代碼示例

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


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

示例1: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):  # pylint: disable=unused-argument
    if self._timer.last_triggered_step() is None:
      # We do write graph and saver_def at the first call of before_run.
      # We cannot do this in begin, since we let other hooks to change graph and
      # add variables in begin. Graph is finalized after all begin calls.
      training_util.write_graph(
          ops.get_default_graph().as_graph_def(add_shapes=True),
          self._checkpoint_dir,
          "graph.pbtxt")
      saver_def = self._get_saver().saver_def if self._get_saver() else None
      graph = ops.get_default_graph()
      meta_graph_def = meta_graph.create_meta_graph_def(
          graph_def=graph.as_graph_def(add_shapes=True),
          saver_def=saver_def)
      self._summary_writer.add_graph(graph)
      self._summary_writer.add_meta_graph(meta_graph_def)

    return SessionRunArgs(self._global_step_tensor) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:20,代碼來源:basic_session_run_hooks.py

示例2: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):  # pylint: disable=unused-argument
    if self._timer.last_triggered_step() is None:
      # Write graph in the first call.
      training_util.write_graph(
          ops.get_default_graph().as_graph_def(add_shapes=True),
          self._checkpoint_dir,
          "graph.pbtxt")
      saver_def = self._saver.saver_def if self._saver else None
      graph = ops.get_default_graph()
      meta_graph_def = meta_graph.create_meta_graph_def(
          graph_def=graph.as_graph_def(add_shapes=True),
          saver_def=saver_def)
      self._summary_writer.add_graph(graph)
      self._summary_writer.add_meta_graph(meta_graph_def)

    return SessionRunArgs(self._global_step_tensor) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:18,代碼來源:basic_session_run_hooks.py

示例3: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    if not self._wrapper_initialized:
      # TODO(cais): Make this hook have a DumpingDebugWrapperSession property
      # instead of subclassing DumpingDebugWrapperSession.
      dumping_wrapper.DumpingDebugWrapperSession.__init__(
          self,
          run_context.session,
          self._session_root,
          watch_fn=self._watch_fn,
          thread_name_filter=self._thread_name_filter,
          log_usage=self._log_usage)
      self._wrapper_initialized = True

    self._run_call_count += 1

    debug_urls, watch_options = self._prepare_run_watch_config(
        run_context.original_args.fetches, run_context.original_args.feed_dict)
    run_options = config_pb2.RunOptions()
    debug_utils.watch_graph(
        run_options,
        run_context.session.graph,
        debug_urls=debug_urls,
        debug_ops=watch_options.debug_ops,
        node_name_regex_whitelist=watch_options.node_name_regex_whitelist,
        op_type_regex_whitelist=watch_options.op_type_regex_whitelist,
        tensor_dtype_regex_whitelist=watch_options.tensor_dtype_regex_whitelist,
        tolerate_debug_op_creation_failures=(
            watch_options.tolerate_debug_op_creation_failures))

    run_args = session_run_hook.SessionRunArgs(
        None, feed_dict=None, options=run_options)
    return run_args 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:34,代碼來源:hooks.py

示例4: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    return session_run_hook.SessionRunArgs({
        'evals_completed': self._evals_completed
    }) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:evaluation.py

示例5: run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def run(self, fetches, feed_dict=None, options=None, run_metadata=None):
    """See base class."""
    if self.should_stop():
      raise RuntimeError('Run called even after should_stop requested.')

    actual_fetches = {'caller': fetches}

    run_context = session_run_hook.SessionRunContext(
        original_args=session_run_hook.SessionRunArgs(fetches, feed_dict),
        session=self._sess)

    options = options or config_pb2.RunOptions()
    feed_dict = self._call_hook_before_run(run_context, actual_fetches,
                                           feed_dict, options)

    # Do session run.
    run_metadata = run_metadata or config_pb2.RunMetadata()
    outputs = _WrappedSession.run(self,
                                  fetches=actual_fetches,
                                  feed_dict=feed_dict,
                                  options=options,
                                  run_metadata=run_metadata)

    for hook in self._hooks:
      hook.after_run(
          run_context,
          session_run_hook.SessionRunValues(
              results=outputs[hook] if hook in outputs else None,
              options=options,
              run_metadata=run_metadata))
    self._should_stop = self._should_stop or run_context.stop_requested

    return outputs['caller'] 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:35,代碼來源:monitored_session.py

示例6: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    return session_run_hook.SessionRunArgs(
        {'global_step': contrib_framework.get_global_step(),
         'current_loss': run_context.session.graph.get_operation_by_name(
             LOSS_NAME).outputs[0]}) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:random_forest.py

示例7: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    """Return the update_weights op so that it is executed during this run."""
    return session_run_hook.SessionRunArgs(self._update_op) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:5,代碼來源:sdca_estimator.py

示例8: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    del run_context
    return SessionRunArgs(
        fetches={KMeansClustering.LOSS_OP_NAME: self._loss_tensor}) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:kmeans.py

示例9: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    self._request_summary = (
        self._next_step is None or
        self._timer.should_trigger_for_step(self._next_step))
    requests = {"global_step": self._global_step_tensor}
    opts = (config_pb2.RunOptions(trace_level=config_pb2.RunOptions.FULL_TRACE)
            if self._request_summary else None)

    return SessionRunArgs(requests, options=opts) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:11,代碼來源:profiler_hook.py

示例10: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    if not self._wrapper_initialized:
      local_cli_wrapper.LocalCLIDebugWrapperSession.__init__(
          self, run_context.session, ui_type=self._ui_type)
      self._wrapper_initialized = True

    # Increment run call counter.
    self._run_call_count += 1

    # Adapt run_context to an instance of OnRunStartRequest for invoking
    # superclass on_run_start().
    on_run_start_request = framework.OnRunStartRequest(
        run_context.original_args.fetches, run_context.original_args.feed_dict,
        None, None, self._run_call_count)

    on_run_start_response = self.on_run_start(on_run_start_request)
    self._performed_action = on_run_start_response.action

    run_args = session_run_hook.SessionRunArgs(
        None, feed_dict=None, options=config_pb2.RunOptions())
    if self._performed_action == framework.OnRunStartAction.DEBUG_RUN:
      self._decorate_options_for_debug(run_args.options,
                                       run_context.session.graph)
    elif self._performed_action == framework.OnRunStartAction.INVOKE_STEPPER:
      # The _finalized property must be set to False so that the NodeStepper
      # can insert ops for retrieving TensorHandles.
      # pylint: disable=protected-access
      run_context.session.graph._finalized = False
      # pylint: enable=protected-access

      self.invoke_node_stepper(
          stepper.NodeStepper(run_context.session, run_context.original_args.
                              fetches, run_context.original_args.feed_dict),
          restore_variable_values_on_exit=True)

    return run_args 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:38,代碼來源:hooks.py

示例11: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):  # pylint: disable=unused-argument
    self._should_trigger = self._timer.should_trigger_for_step(self._iter_count)
    if self._should_trigger:
      return SessionRunArgs(self._current_tensors)
    else:
      return None 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:8,代碼來源:basic_session_run_hooks.py

示例12: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
      del run_context
      return SessionRunArgs(
          fetches={KMeansClustering.LOSS_OP_NAME: self._loss_tensor}) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:6,代碼來源:kmeans.py

示例13: before_run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunArgs [as 別名]
def before_run(self, run_context):
    return session_run_hook.SessionRunArgs(self._updated_global_step) 
開發者ID:IntelAI,項目名稱:models,代碼行數:4,代碼來源:run_squad.py


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