reshape_tail

tfsnippet.ops.reshape_tail(input, ndims, shape, name=None)

Reshape the tail (last) ndims into specified shape.

Usage:

x = tf.zeros([2, 3, 4, 5, 6])
reshape_tail(x, 3, [-1])  # output: zeros([2, 3, 120])
reshape_tail(x, 1, [3, 2])  # output: zeros([2, 3, 4, 5, 3, 2])
Parameters:
  • input (Tensor) – The input tensor, at least ndims dimensions.
  • ndims (int) – To reshape this number of dimensions at tail.
  • shape (Iterable[int] or tf.Tensor) – The shape of the new tail.
  • name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns:

The reshaped tensor.

Return type:

tf.Tensor