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

Method run

tensorflow/python/client/session.py:855–974  ·  view source on GitHub ↗

Runs operations and evaluates tensors in `fetches`. This method runs one "step" of TensorFlow computation, by running the necessary graph fragment to execute every `Operation` and evaluate every `Tensor` in `fetches`, substituting the values in `feed_dict` for the corresponding inpu

(self, fetches, feed_dict=None, options=None, run_metadata=None)

Source from the content-addressed store, hash-verified

853 return ops.default_session(self)
854
855 def run(self, fetches, feed_dict=None, options=None, run_metadata=None):
856 """Runs operations and evaluates tensors in `fetches`.
857
858 This method runs one "step" of TensorFlow computation, by
859 running the necessary graph fragment to execute every `Operation`
860 and evaluate every `Tensor` in `fetches`, substituting the values in
861 `feed_dict` for the corresponding input values.
862
863 The `fetches` argument may be a single graph element, or an arbitrarily
864 nested list, tuple, namedtuple, dict, or OrderedDict containing graph
865 elements at its leaves. A graph element can be one of the following types:
866
867 * A `tf.Operation`.
868 The corresponding fetched value will be `None`.
869 * A `tf.Tensor`.
870 The corresponding fetched value will be a numpy ndarray containing the
871 value of that tensor.
872 * A `tf.SparseTensor`.
873 The corresponding fetched value will be a
874 `tf.compat.v1.SparseTensorValue`
875 containing the value of that sparse tensor.
876 * A `get_tensor_handle` op. The corresponding fetched value will be a
877 numpy ndarray containing the handle of that tensor.
878 * A `string` which is the name of a tensor or operation in the graph.
879
880 The value returned by `run()` has the same shape as the `fetches` argument,
881 where the leaves are replaced by the corresponding values returned by
882 TensorFlow.
883
884 Example:
885
886 ```python
887 a = tf.constant([10, 20])
888 b = tf.constant([1.0, 2.0])
889 # 'fetches' can be a singleton
890 v = session.run(a)
891 # v is the numpy array [10, 20]
892 # 'fetches' can be a list.
893 v = session.run([a, b])
894 # v is a Python list with 2 numpy arrays: the 1-D array [10, 20] and the
895 # 1-D array [1.0, 2.0]
896 # 'fetches' can be arbitrary lists, tuples, namedtuple, dicts:
897 MyData = collections.namedtuple('MyData', ['a', 'b'])
898 v = session.run({'k1': MyData(a, b), 'k2': [b, a]})
899 # v is a dict with
900 # v['k1'] is a MyData namedtuple with 'a' (the numpy array [10, 20]) and
901 # 'b' (the numpy array [1.0, 2.0])
902 # v['k2'] is a list with the numpy array [1.0, 2.0] and the numpy array
903 # [10, 20].
904 ```
905
906 The optional `feed_dict` argument allows the caller to override
907 the value of tensors in the graph. Each key in `feed_dict` can be
908 one of the following types:
909
910 * If the key is a `tf.Tensor`, the
911 value may be a Python scalar, string, list, or numpy ndarray
912 that can be converted to the same `dtype` as that

Callers 15

_generic_runMethod · 0.95
_register_dead_handleMethod · 0.95
_update_with_moversMethod · 0.95
RunTestManyPartialRunMethod · 0.45
_benchmarkFeedMethod · 0.45
_benchmarkFetchMethod · 0.45
_benchmarkRunOpMethod · 0.45
testSimpleTimelineMethod · 0.45
testTimelineCpuMethod · 0.45
testTimelineGpuMethod · 0.45

Calls 3

_runMethod · 0.95
SerializeToStringMethod · 0.45
ParseFromStringMethod · 0.45

Tested by 15

RunTestManyPartialRunMethod · 0.36
testSimpleTimelineMethod · 0.36
testTimelineCpuMethod · 0.36
testTimelineGpuMethod · 0.36
testManyCPUsMethod · 0.36
testErrorsReportedMethod · 0.36
testFetchNoneMethod · 0.36
testFetchSingletonMethod · 0.36