def make_view(*args, **kwargs): """Create a SubGraphView from selected operations and passthrough tensors. Args: *args: list of 1) regular expressions (compiled or not) or 2) (array of) tf.Operation 3) (array of) tf.Tensor. Those objects will be converted into a list of operations and a list of candidate for passthrough tensors. **kwargs: keyword graph is used 1) to check that the ops and ts are from the correct graph 2) for regular expression query Returns: A subgraph view. Raises: TypeError: if the optional keyword argument graph is not a tf.Graph or if an argument in args is not an (array of) tf.Tensor or an (array of) tf.Operation or a string or a regular expression. ValueError: if one of the keyword arguments is unexpected. """ # get keywords arguments graph = kwargs["graph"] if "graph" in kwargs else None # already a view? if len(args) == 1 and isinstance(args[0], SubGraphView): return _check_graph(args[0], graph) ops, ts = select.select_ops_and_ts(*args, **kwargs) sgv = SubGraphView(ops, ts) return _check_graph(sgv, graph)
def make_view(*args, **kwargs): """Create a SubGraphView from selected operations and passthrough tensors. Args: *args: list of 1) regular expressions (compiled or not) or 2) (array of) tf.Operation 3) (array of) tf.Tensor. Those objects will be converted into a list of operations and a list of candidate for passthrough tensors. **kwargs: keyword graph is used 1) to check that the ops and ts are from the correct graph 2) for regular expression query Returns: A subgraph view. Raises: TypeError: if the optional keyword argument graph is not a tf.Graph or if an argument in args is not an (array of) tf.Tensor or an (array of) tf.Operation or a string or a regular expression. ValueError: if one of the keyword arguments is unexpected. """ # get keywords arguments graph = kwargs["graph"] if "graph" in kwargs else None # already a view? if len(args) == 1 and isinstance(args[0], SubGraphView): return _check_graph(args[0], graph) ops, ts = select.select_ops_and_ts(*args, **kwargs) sgv = SubGraphView(ops, ts) return _check_graph(sgv, graph)