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

Function _eval_using_default_session

tensorflow/python/framework/ops.py:5450–5487  ·  view source on GitHub ↗

Uses the default session to evaluate one or more tensors. Args: tensors: A single Tensor, or a list of Tensor objects. feed_dict: A dictionary that maps Tensor objects (or tensor names) to lists, numpy ndarrays, TensorProtos, or strings. graph: The graph in which the tensors are

(tensors, feed_dict, graph, session=None)

Source from the content-addressed store, hash-verified

5448
5449
5450def _eval_using_default_session(tensors, feed_dict, graph, session=None):
5451 """Uses the default session to evaluate one or more tensors.
5452
5453 Args:
5454 tensors: A single Tensor, or a list of Tensor objects.
5455 feed_dict: A dictionary that maps Tensor objects (or tensor names) to lists,
5456 numpy ndarrays, TensorProtos, or strings.
5457 graph: The graph in which the tensors are defined.
5458 session: (Optional) A different session to use to evaluate "tensors".
5459
5460 Returns:
5461 Either a single numpy ndarray if "tensors" is a single tensor; or a list
5462 of numpy ndarrays that each correspond to the respective element in
5463 "tensors".
5464
5465 Raises:
5466 ValueError: If no default session is available; the default session
5467 does not have "graph" as its graph; or if "session" is specified,
5468 and it does not have "graph" as its graph.
5469 """
5470 if session is None:
5471 session = get_default_session()
5472 if session is None:
5473 raise ValueError("Cannot evaluate tensor using `eval()`: No default "
5474 "session is registered. Use `with "
5475 "sess.as_default()` or pass an explicit session to "
5476 "`eval(session=sess)`")
5477 if session.graph is not graph:
5478 raise ValueError("Cannot use the default session to evaluate tensor: "
5479 "the tensor's graph is different from the session's "
5480 "graph. Pass an explicit session to "
5481 "`eval(session=sess)`.")
5482 else:
5483 if session.graph is not graph:
5484 raise ValueError("Cannot use the given session to evaluate tensor: "
5485 "the tensor's graph is different from the session's "
5486 "graph.")
5487 return session.run(tensors, feed_dict)
5488
5489
5490def _run_using_default_session(operation, feed_dict, graph, session=None):

Callers 2

evalMethod · 0.85
evalMethod · 0.85

Calls 2

get_default_sessionFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected