oneflow.unbind

oneflow.unbind()

Removes a tensor dimension.

Returns a tuple of all slices along a given dimension, already without it.

This function is equivalent to PyTorch’s unbind function.

Parameters
  • x (Tensor) – the tensor to unbind

  • dim (int) – dimension to remove

For example:

>>> import oneflow as flow

>>> x = flow.tensor(range(12)).reshape([3,4])
>>> flow.unbind(x)
(tensor([0, 1, 2, 3], dtype=oneflow.int64), tensor([4, 5, 6, 7], dtype=oneflow.int64), tensor([ 8,  9, 10, 11], dtype=oneflow.int64))
>>> flow.unbind(x, 1)
(tensor([0, 4, 8], dtype=oneflow.int64), tensor([1, 5, 9], dtype=oneflow.int64), tensor([ 2,  6, 10], dtype=oneflow.int64), tensor([ 3,  7, 11], dtype=oneflow.int64))