MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_op_or_tensor_by_name

Function get_op_or_tensor_by_name

tensorpack/tfutils/common.py:120–141  ·  view source on GitHub ↗

Get either tf.Operation of tf.Tensor from names. Args: name (list[str] or str): names of operations or tensors. Raises: KeyError, if the name doesn't exist

(name)

Source from the content-addressed store, hash-verified

118
119
120def get_op_or_tensor_by_name(name):
121 """
122 Get either tf.Operation of tf.Tensor from names.
123
124 Args:
125 name (list[str] or str): names of operations or tensors.
126
127 Raises:
128 KeyError, if the name doesn't exist
129 """
130 G = tfv1.get_default_graph()
131
132 def f(n):
133 if len(n) >= 3 and n[-2] == ':':
134 return G.get_tensor_by_name(n)
135 else:
136 return G.get_operation_by_name(n)
137
138 if not isinstance(name, list):
139 return f(name)
140 else:
141 return list(map(f, name))
142
143
144def gpu_available_in_session():

Callers 4

before_runMethod · 0.85
get_tensorMethod · 0.85
get_tensorMethod · 0.85
get_variableMethod · 0.85

Calls 1

fFunction · 0.70

Tested by

no test coverage detected