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)
| 118 | |
| 119 | |
| 120 | def 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 | |
| 144 | def gpu_available_in_session(): |
no test coverage detected