本文整理匯總了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']
示例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)
示例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']