MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _run_using_default_session

Function _run_using_default_session

tensorflow/python/framework/ops.py:5490–5522  ·  view source on GitHub ↗

Uses the default session to run "operation". Args: operation: The Operation to be run. feed_dict: A dictionary that maps Tensor objects (or tensor names) to lists, numpy ndarrays, TensorProtos, or strings. graph: The graph in which "operation" is defined. session: (Optional)

(operation, feed_dict, graph, session=None)

Source from the content-addressed store, hash-verified

5488
5489
5490def _run_using_default_session(operation, feed_dict, graph, session=None):
5491 """Uses the default session to run "operation".
5492
5493 Args:
5494 operation: The Operation to be run.
5495 feed_dict: A dictionary that maps Tensor objects (or tensor names) to lists,
5496 numpy ndarrays, TensorProtos, or strings.
5497 graph: The graph in which "operation" is defined.
5498 session: (Optional) A different session to use to run "operation".
5499
5500 Raises:
5501 ValueError: If no default session is available; the default session
5502 does not have "graph" as its graph; or if "session" is specified,
5503 and it does not have "graph" as its graph.
5504 """
5505 if session is None:
5506 session = get_default_session()
5507 if session is None:
5508 raise ValueError("Cannot execute operation using `run()`: No default "
5509 "session is registered. Use `with "
5510 "sess.as_default():` or pass an explicit session to "
5511 "`run(session=sess)`")
5512 if session.graph is not graph:
5513 raise ValueError("Cannot use the default session to execute operation: "
5514 "the operation's graph is different from the "
5515 "session's graph. Pass an explicit session to "
5516 "run(session=sess).")
5517 else:
5518 if session.graph is not graph:
5519 raise ValueError("Cannot use the given session to execute operation: "
5520 "the operation's graph is different from the session's "
5521 "graph.")
5522 session.run(operation, feed_dict)
5523
5524
5525class _DefaultGraphStack(_DefaultStack): # pylint: disable=protected-access

Callers 1

runMethod · 0.85

Calls 2

get_default_sessionFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected