本文整理匯總了Python中tensorflow.python.client.session.run方法的典型用法代碼示例。如果您正苦於以下問題:Python session.run方法的具體用法?Python session.run怎麽用?Python session.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.client.session
的用法示例。
在下文中一共展示了session.run方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_run_start
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def on_run_start(self, request):
"""Callback invoked on run() calls to the debug-wrapper session.
This is a blocking callback.
The invocation happens after the wrapper's run() call is entered,
after an increment of run call counter.
Args:
request: (OnRunStartRequest) callback request object carrying information
about the run call such as the fetches, feed dict, run options, run
metadata, and how many run() calls to this wrapper session has occurred.
Returns:
An instance of OnRunStartResponse, carrying information to
1) direct the wrapper session to perform a specified action (e.g., run
with or without debug tensor watching, invoking the stepper.)
2) debug URLs used to watch the tensors.
"""
pass
示例2: __init__
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
run_call_count):
"""Constructor of `OnRunStartRequest`.
Args:
fetches: Fetch targets of the run() call.
feed_dict: The feed dictionary to the run() call.
run_options: RunOptions input to the run() call.
run_metadata: RunMetadata input to the run() call.
The above four arguments are identical to the input arguments to the
run() method of a non-wrapped TensorFlow session.
run_call_count: 1-based count of how many run calls (including this one)
has been invoked.
"""
self.fetches = fetches
self.feed_dict = feed_dict
self.run_options = run_options
self.run_metadata = run_metadata
self.run_call_count = run_call_count
示例3: on_run_start
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def on_run_start(self, request):
"""Callback invoked on run() calls to the debug-wrapper session.
This is a blocking callback.
The invocation happens after the wrapper's run() call is entered,
after an increment of run call counter.
Args:
request: (`OnRunStartRequest`) callback request object carrying
information about the run call such as the fetches, feed dict, run
options, run metadata, and how many `run()` calls to this wrapper
session have occurred.
Returns:
An instance of `OnRunStartResponse`, carrying information to
1) direct the wrapper session to perform a specified action (e.g., run
with or without debug tensor watching, invoking the stepper.)
2) debug URLs used to watch the tensors.
"""
示例4: invoke_node_stepper
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def invoke_node_stepper(self,
node_stepper,
restore_variable_values_on_exit=True):
"""Callback invoked when the client intends to step through graph nodes.
Args:
node_stepper: (stepper.NodeStepper) An instance of NodeStepper to be used
in this stepping session.
restore_variable_values_on_exit: (bool) Whether any variables whose values
have been altered during this node-stepper invocation should be restored
to their old values when this invocation ends.
Returns:
The same return values as the `Session.run()` call on the same fetches as
the NodeStepper.
"""
示例5: _prepare_run_watch_config
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def _prepare_run_watch_config(self, fetches, feed_dict):
"""Get the debug_urls, and node/op whitelists for the current run() call.
Args:
fetches: Same as the `fetches` argument to `Session.run()`.
feed_dict: Same as the `feed_dict argument` to `Session.run()`.
Returns:
debug_urls: (str or list of str) Debug URLs for the current run() call.
Currently, the list consists of only one URL that is a file:// URL.
watch_options: (WatchOptions) The return value of a watch_fn, containing
options including debug_ops, and whitelists.
"""
debug_urls = self.prepare_run_debug_urls(fetches, feed_dict)
if self._watch_fn is None:
watch_options = WatchOptions()
else:
watch_options = self._watch_fn(fetches, feed_dict)
if isinstance(watch_options, tuple):
# For legacy return type (tuples).
watch_options = WatchOptions(*watch_options)
return debug_urls, watch_options
示例6: run
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def run(args):
"""Function triggered by run command.
Args:
args: A namespace parsed from command line.
Raises:
AttributeError: An error when neither --inputs nor --input_exprs is passed
to run command.
"""
if not args.inputs and not args.input_exprs:
raise AttributeError(
'At least one of --inputs and --input_exprs must be required')
tensor_key_feed_dict = load_inputs_from_input_arg_string(
args.inputs, args.input_exprs)
run_saved_model_with_feed_dict(args.dir, args.tag_set, args.signature_def,
tensor_key_feed_dict, args.outdir,
args.overwrite, tf_debug=args.tf_debug)
示例7: __init__
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
run_call_count):
"""Constructor of OnRunStartRequest.
Args:
fetches: Fetch targets of the run() call.
feed_dict: The feed dictionary to the run() call.
run_options: RunOptions input to the run() call.
run_metadata: RunMetadata input to the run() call.
The above four arguments are identical to the input arguments to the
run() method of a non-wrapped TensorFlow session.
run_call_count: 1-based count of how many run calls (including this one)
has been invoked.
"""
self.fetches = fetches
self.feed_dict = feed_dict
self.run_options = run_options
self.run_metadata = run_metadata
self.run_call_count = run_call_count
示例8: __init__
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
run_call_count, is_callable_runner=False):
"""Constructor of `OnRunStartRequest`.
Args:
fetches: Fetch targets of the run() call.
feed_dict: The feed dictionary to the run() call.
run_options: RunOptions input to the run() call.
run_metadata: RunMetadata input to the run() call.
The above four arguments are identical to the input arguments to the
run() method of a non-wrapped TensorFlow session.
run_call_count: 1-based count of how many run calls (including this one)
has been invoked.
is_callable_runner: (bool) whether a runner returned by
Session.make_callable is being run.
"""
self.fetches = fetches
self.feed_dict = feed_dict
self.run_options = run_options
self.run_metadata = run_metadata
self.run_call_count = run_call_count
self.is_callable_runner = is_callable_runner
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:24,代碼來源:framework.py
示例9: __enter__
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def __enter__(self):
self.old_run = getattr(session.BaseSession, 'run', None)
self.old_init = getattr(session.BaseSession, '__init__', None)
if not self.old_run:
raise errors.InternalError(None, None, 'BaseSession misses run method.')
elif not self.old_init:
raise errors.InternalError(None, None,
'BaseSession misses __init__ method.')
elif getattr(session.BaseSession, '_profiler_run_internal', None):
raise errors.InternalError(None, None,
'Already in context or context not cleaned.')
elif getattr(session.BaseSession, '_profiler_init_internal', None):
raise errors.InternalError(None, None,
'Already in context or context not cleaned.')
else:
setattr(session.BaseSession, 'run', _profiled_run)
setattr(session.BaseSession, '__init__', _profiled_init)
setattr(session.BaseSession, '_profiler_run_internal', self.old_run)
setattr(session.BaseSession, '_profiler_init_internal', self.old_init)
setattr(session.BaseSession, 'profile_context', self)
return self
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:23,代碼來源:profile_context.py
示例10: prepare_run_debug_urls
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def prepare_run_debug_urls(self, fetches, feed_dict):
"""Abstract method to be implemented by concrete subclasses.
This method prepares the run-specific debug URL(s).
Args:
fetches: Same as the `fetches` argument to `Session.run()`
feed_dict: Same as the `feed_dict` argument to `Session.run()`
Returns:
debug_urls: (`str` or `list` of `str`) Debug URLs to be used in
this `Session.run()` call.
"""
示例11: _prepare_run_debug_urls
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def _prepare_run_debug_urls(self, fetches, feed_dict):
"""Abstract method to be implemented by concrete subclasses.
This method prepares the run-specific debug URL(s).
Args:
fetches: Same as the `fetches` argument to `Session.run()`
feed_dict: Same as the `feed_dict` argument to `Session.run()`
Returns:
debug_urls: (`str` or `list` of `str`) Debug URLs to be used in
this `Session.run()` call.
"""
示例12: _prepare_run_watch_config
# 需要導入模塊: from tensorflow.python.client import session [as 別名]
# 或者: from tensorflow.python.client.session import run [as 別名]
def _prepare_run_watch_config(self, fetches, feed_dict):
"""Get the debug_urls, and node/op whitelists for the current run() call.
Args:
fetches: Same as the `fetches` argument to `Session.run()`.
feed_dict: Same as the `feed_dict argument` to `Session.run()`.
Returns:
debug_urls: (str or list of str) Debug URLs for the current run() call.
Currently, the list consists of only one URL that is a file:// URL.
debug_ops: (str or list of str) Debug op(s) to be used by the
debugger.
node_name_regex_whitelist: (str or regex) Regular-expression whitelist for
node name. Same as the same-name argument to debug_utils.watch_graph.
op_type_regex_whitelist: (str or regex) Regular-expression whitelist for
op type. Same as the same-name argument to debug_utils.watch_graph.
"""
debug_urls = self._prepare_run_debug_urls(fetches, feed_dict)
debug_ops = "DebugIdentity"
node_name_regex_whitelist = None
op_type_regex_whitelist = None
if self._watch_fn is not None:
debug_ops, node_name_regex_whitelist, op_type_regex_whitelist = (
self._watch_fn(fetches, feed_dict))
return (debug_urls, debug_ops, node_name_regex_whitelist,
op_type_regex_whitelist)