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)
| 273 | |
| 274 | |
| 275 | def make_list_of_t(ts, check_graph=True, allow_graph=True, ignore_ops=False): |
| 276 | """Convert ts to a list of `tf.Tensor`. |
| 277 | |
| 278 | Args: |
| 279 | ts: can be an iterable of `tf.Tensor`, a `tf.Graph` or a single tensor. |
| 280 | check_graph: if `True` check if all the tensors belong to the same graph. |
| 281 | allow_graph: if `False` a `tf.Graph` cannot be converted. |
| 282 | ignore_ops: if `True`, silently ignore `tf.Operation`. |
| 283 | Returns: |
| 284 | A newly created list of `tf.Tensor`. |
| 285 | Raises: |
| 286 | TypeError: if `ts` cannot be converted to a list of `tf.Tensor` or, |
| 287 | if `check_graph` is `True`, if all the ops do not belong to the same graph. |
| 288 | """ |
| 289 | if isinstance(ts, tf_ops.Graph): |
| 290 | if allow_graph: |
| 291 | return get_tensors(ts) |
| 292 | else: |
| 293 | raise TypeError("allow_graph is False: cannot convert a tf.Graph.") |
| 294 | else: |
| 295 | if not is_iterable(ts): |
| 296 | ts = [ts] |
| 297 | if not ts: |
| 298 | return [] |
| 299 | if check_graph: |
| 300 | check_types = None if ignore_ops else tf_ops.Tensor |
| 301 | get_unique_graph(ts, check_types=check_types) |
| 302 | return [t for t in ts if isinstance(t, tf_ops.Tensor)] |
| 303 | |
| 304 | |
| 305 | def get_generating_ops(ts): |
no test coverage detected