unbind¶
dragon.vm.torch.
unbind
(
input,
dim=0,
copy=True
)[source]¶Unpack input into chunks along the given dimension.
The number of outputs is equal to the size of dimension:
x = torch.tensor([[1, 2, 3], [4, 5, 6]]) # Shape: (2, 3) -> (3,), (3,) print(torch.unbind(x, dim=0))
dim
can be negative:x = torch.tensor([[1, 2, 3], [4, 5, 6]]) # Shape: (2, 3) -> (2,), (2,), (2,) print(torch.unbind(x, dim=-1))
- Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- dim (int, optional, default=0) – The dimension to unpack.
- copy (bool, optional, default=True) – Copy or create the views of input.
- Returns:
Sequence[dragon.vm.torch.Tensor] – The output tensors.