unfold#

ivy.unfold(x, /, mode=0, *, out=None)[source]#

Return the mode-mode unfolding of tensor with modes starting at 0.

Parameters:
  • x (Union[Array, NativeArray]) – input tensor to be unfolded

  • mode (int, default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – unfolded_tensor of shape (tensor.shape[mode], -1)

Array.unfold(self, /, mode=0, *, out=None)[source]#

ivy.Array instance method variant of ivy.unfold. This method simply wraps the function, and so the docstring for ivy.unfold also applies to this method with minimal changes.

Parameters:
  • self (Union[Array, NativeArray]) – input tensor to be unfolded

  • mode (Optional[int], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – unfolded_tensor of shape (tensor.shape[mode], -1)

Container.unfold(self, /, mode=0, *, out=None)[source]#

ivy.Container instance method variant of ivy.unfold.

This method simply wraps the function, and so the docstring for ivy.unfold also applies to this method with minimal changes.

Parameters:
  • self (Container) – input tensor to be unfolded

  • mode (Optional[Union[int, Container]], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – Container of unfolded tensors