Module: util

tf.contrib.graph_editor.make_list_of_op(ops, check_graph=True, allow_graph=True, ignore_ts=False)

Convert ops to a list of tf.Operation.

Args:
  • ops: can be an iterable of tf.Operation, a tf.Graph or a single operation.
  • check_graph: if True check if all the operations belong to the same graph.
  • allow_graph: if False a tf.Graph cannot be converted.
  • ignore_ts: if True, silently ignore tf.Tensor.
Returns:

A newly created list of tf.Operation.

Raises:
  • TypeError: if ops cannot be converted to a list of tf.Operation or, if check_graph is True, if all the ops do not belong to the same graph.

tf.contrib.graph_editor.get_tensors(graph)

get all the tensors which are input or output of an op in the graph.

Args:
  • graph: a tf.Graph.
Returns:

A list of tf.Tensor.

Raises:
  • TypeError: if graph is not a tf.Graph.

tf.contrib.graph_editor.make_list_of_t(ts, check_graph=True, allow_graph=True, ignore_ops=False)

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 ignore tf.Operation.
Returns:

A newly created list of tf.Tensor.

Raises:
  • TypeError: if ts cannot be converted to a list of tf.Tensor or, if check_graph is True, if all the ops do not belong to the same graph.

tf.contrib.graph_editor.get_generating_ops(ts)

Return all the generating ops of the tensors in ts.

Args:
  • ts: a list of tf.Tensor
Returns:

A list of all the generating tf.Operation of the tensors in ts.

Raises:
  • TypeError: if ts cannot be converted to a list of tf.Tensor.

tf.contrib.graph_editor.get_consuming_ops(ts)

Return all the consuming ops of the tensors in ts.

Args:
  • ts: a list of tf.Tensor
Returns:

A list of all the consuming tf.Operation of the tensors in ts.

Raises:
  • TypeError: if ts cannot be converted to a list of tf.Tensor.

class tf.contrib.graph_editor.ControlOutputs

The control outputs topology.


tf.contrib.graph_editor.ControlOutputs.__init__(graph) {:#ControlOutputs.init}

Create a dictionary of control-output dependencies.

Args:
  • graph: a tf.Graph.
Returns:

A dictionary where a key is a tf.Operation instance and the corresponding value is a list of all the ops which have the key as one of their control-input dependencies.

Raises:
  • TypeError: graph is not a tf.Graph.

tf.contrib.graph_editor.ControlOutputs.get(op)

return the control outputs of op.


tf.contrib.graph_editor.ControlOutputs.get_all()


tf.contrib.graph_editor.ControlOutputs.graph


tf.contrib.graph_editor.ControlOutputs.update()

Update the control outputs if the graph has changed.


tf.contrib.graph_editor.placeholder_name(t=None, scope=None)

Create placeholder name for tjhe graph editor.

Args:
  • t: optional tensor on which the placeholder operation's name will be based on
  • scope: absolute scope with which to predix the placeholder's name. None means that the scope of t is preserved. "" means the root scope.
Returns:

A new placeholder name prefixed by "geph". Note that "geph" stands for Graph Editor PlaceHolder. This convention allows to quickly identify the placeholder generated by the Graph Editor.

Raises:
  • TypeError: if t is not None or a tf.Tensor.

tf.contrib.graph_editor.make_placeholder_from_tensor(t, scope=None)

Create a tf.placeholder for the Graph Editor.

Note that the correct graph scope must be set by the calling function.

Args:
  • t: a tf.Tensor whose name will be used to create the placeholder (see function placeholder_name).
  • scope: absolute scope within which to create the placeholder. None means that the scope of t is preserved. "" means the root scope.
Returns:

A newly created tf.placeholder.

Raises:
  • TypeError: if t is not None or a tf.Tensor.

tf.contrib.graph_editor.make_placeholder_from_dtype_and_shape(dtype, shape=None, scope=None)

Create a tf.placeholder for the Graph Editor.

Note that the correct graph scope must be set by the calling function. The placeholder is named using the function placeholder_name (with no tensor argument).

Args:
  • dtype: the tensor type.
  • shape: the tensor shape (optional).
  • scope: absolute scope within which to create the placeholder. None means that the scope of t is preserved. "" means the root scope.
Returns:

A newly created tf.placeholder.