本文整理汇总了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']