reverse

dragon.reverse(
  inputs,
  axis,
  **kwargs
)[source]

Reverse elements along the given axis.

axis could be negative:

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

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

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

dragon.Tensor – The output tensor.