transpose

dragon.transpose(
  inputs,
  perm=None,
  copy=True,
  **kwargs
)[source]

Permute the dimensions of input.

Examples:

# Provide the permutation for all axes
x = dragon.ones(shape=(2, 3, 4))
print(dragon.transpose(x, (0, 2, 1)).shape)  # (2, 4, 3)

# Or dimensions will be simply inverse
print(dragon.transpose(x).shape)  # (4, 3, 2)
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • perm (Union[Sequence[int], dragon.Tensor]], optional) – The output permutation.
  • copy (bool, optional, default=True) – Return a new tensor or call in-place.
Returns:

dragon.Tensor – The output tensor.