Other Functions and Classes

tf.bitcast(input, type, name=None)

Bitcasts a tensor from one type to another without copying data.

Given a tensor input, this operation returns a tensor that has the same buffer data as input with datatype type.

If the input datatype T is larger than the output datatype type then the shape changes from [...] to [..., sizeof(T)/sizeof(type)].

If T is smaller than type, the operator requires that the rightmost dimension be equal to sizeof(type)/sizeof(T). The shape then goes from [..., sizeof(type)/sizeof(T)] to [...].

NOTE: Bitcast is implemented as a low-level cast, so machines with different endian orderings will give different results.

Args:
  • input: A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half.
  • type: A tf.DType from: tf.float32, tf.float64, tf.int64, tf.int32, tf.uint8, tf.uint16, tf.int16, tf.int8, tf.complex64, tf.complex128, tf.qint8, tf.quint8, tf.qint32, tf.half.
  • name: A name for the operation (optional).
Returns:

A Tensor of type type.


tf.contrib.graph_editor.copy(sgv, dst_graph=None, dst_scope='', src_scope='')

Copy a subgraph.

Args:
  • sgv: the source subgraph-view. This argument is converted to a subgraph using the same rules than the function subgraph.make_view.
  • dst_graph: the destination graph.
  • dst_scope: the destination scope.
  • src_scope: the source scope.
Returns:

the subgraph view of the copied subgraph.

Raises:
  • TypeError: if dst_graph is not a tf.Graph.
  • StandardError: if sgv cannot be converted to a SubGraphView using the same rules than the function subgraph.make_view.

tf.shape_n(input, name=None)

Returns shape of tensors.

This operation returns N 1-D integer tensors representing shape of input[i]s.

Args:
  • input: A list of at least 1 Tensor objects of the same type.
  • name: A name for the operation (optional).
Returns:

A list with the same number of Tensor objects as input of Tensor objects of type int32.


tf.unique_with_counts(x, name=None)

Finds unique elements in a 1-D tensor.

This operation returns a tensor y containing all of the unique elements of x sorted in the same order that they occur in x. This operation also returns a tensor idx the same size as x that contains the index of each value of x in the unique output y. Finally, it returns a third tensor count that contains the count of each element of y in x. In other words:

y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]

For example:

# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx, count = unique_with_counts(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
count ==> [2, 1, 3, 1, 2]
Args:
  • x: A Tensor. 1-D.
  • name: A name for the operation (optional).
Returns:

A tuple of Tensor objects (y, idx, count).

  • y: A Tensor. Has the same type as x. 1-D.
  • idx: A Tensor of type int32. 1-D.
  • count: A Tensor of type int32. 1-D.