unstack

dragon.unstack(
  inputs,
  axis=0,
  num=None,
  copy=True,
  **kwargs
)[source]

Unpack input into chunks along the given axis.

The number of outputs should be equal to the dimension of axis:

x = dragon.constant([[1, 2, 3], [4, 5, 6]])
# Shape: (2, 3) -> (3,), (3,)
print(dragon.unstack(x, axis=0))

axis can be negative:

x = dragon.constant([[1, 2, 3], [4, 5, 6]])
# Shape: (2, 3) -> (2,), (2,), (2,)
print(dragon.unstack(x, axis=-1))
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • axis (int, optional, default=0) – The axis to unpack.
  • num (int, optional) – The number of outputs.
  • copy (bool, optional, default=True) – Copy or create the views of input.
Returns:

Sequence[dragon.Tensor] – The output tensors.