reverse

dragon.vm.tensorflow.reverse(
  tensor,
  axis,
  name=None
)[source]

Reverse elements along the given axis.

axis could be negative:

x = tf.constant([[1, 2, 3], [4, 5, 6]])

# A negative axis is the last-k axis
print(tf.reverse(x, axis=1))  # [[3, 2, 1], [6, 5, 4]]
print(tf.reverse(x, axis=-1))  # Equivalent

# Also, axis could be a sequence of integers
print(tf.reverse(x, axis=(0, 1)))  # [[6, 5, 4], [3, 2, 1]]
Parameters:
  • tensor (dragon.Tensor) – The input tensor.
  • axis (Union[int, Sequence[int]]) – The axis to reverse.
  • name (str, optional) – The operation name.
Returns:

dragon.Tensor – The output tensor.