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


Python session_run_hook.SessionRunContext方法代碼示例

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


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

示例1: run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunContext [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

示例2: end

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunContext [as 別名]
def end(self, session):  # pylint: disable=unused-argument
    """Runs evaluator for final model."""
    step = session.run(self._global_step_tensor)
    run_ctx = session_run_hook.SessionRunContext({}, session)
    self._predict(run_ctx, step) 
開發者ID:mlperf,項目名稱:training_results_v0.5,代碼行數:7,代碼來源:in_memory_eval.py

示例3: run

# 需要導入模塊: from tensorflow.python.training import session_run_hook [as 別名]
# 或者: from tensorflow.python.training.session_run_hook import SessionRunContext [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)
    feed_dict = self._call_hook_before_run(
        run_context, actual_fetches, feed_dict)

    # Do session run.
    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))
    self._should_stop = self._should_stop or run_context.stop_requested

    return outputs['caller'] 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:30,代碼來源:monitored_session.py


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