Convert ts to a list of `tf.Tensor`. Args: ts: can be an iterable of `tf.Tensor`, a `tf.Graph` or a single tensor. check_graph: if `True` check if all the tensors belong to the same graph. allow_graph: if `False` a `tf.Graph` cannot be converted. ignore_ops: if `True`, silently ig
(ts, check_graph=True, allow_graph=True, ignore_ops=False)
| 132 | |
| 133 | |
| 134 | def make_list_of_t(ts, check_graph=True, allow_graph=True, ignore_ops=False): |
| 135 | """Convert ts to a list of `tf.Tensor`. |
| 136 | |
| 137 | Args: |
| 138 | ts: can be an iterable of `tf.Tensor`, a `tf.Graph` or a single tensor. |
| 139 | check_graph: if `True` check if all the tensors belong to the same graph. |
| 140 | allow_graph: if `False` a `tf.Graph` cannot be converted. |
| 141 | ignore_ops: if `True`, silently ignore `tf.Operation`. |
| 142 | Returns: |
| 143 | A newly created list of `tf.Tensor`. |
| 144 | Raises: |
| 145 | TypeError: if `ts` cannot be converted to a list of `tf.Tensor` or, |
| 146 | if `check_graph` is `True`, if all the ops do not belong to the same graph. |
| 147 | """ |
| 148 | if isinstance(ts, ops.Graph): |
| 149 | if allow_graph: |
| 150 | return get_tensors(ts) |
| 151 | else: |
| 152 | raise TypeError("allow_graph is False: cannot convert a tf.Graph.") |
| 153 | else: |
| 154 | if not is_iterable(ts): |
| 155 | ts = [ts] |
| 156 | if not ts: |
| 157 | return [] |
| 158 | if check_graph: |
| 159 | check_types = None if ignore_ops else ops.Tensor |
| 160 | get_unique_graph(ts, check_types=check_types) |
| 161 | return [t for t in ts if isinstance(t, ops.Tensor)] |
| 162 | |
| 163 | |
| 164 | def get_generating_ops(ts): |
no test coverage detected