partial_unfold#

ivy.partial_unfold(x, /, mode=0, skip_begin=1, skip_end=0, ravel_tensors=False, *, out=None)[source]#

Partial unfolding of a tensor while ignoring the specified number of dimensions at the beginning and the end. For instance, if the first dimension of the tensor is the number of samples, to unfold each sample, set skip_begin=1. This would, for each i in range(tensor.shape[0]), unfold tensor[i, ...].

Parameters:
  • x (Union[Array, NativeArray]) – tensor of shape n_samples x n_1 x n_2 x … x n_i

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

  • skip_begin (int, default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (int, default: 0) – number of dimensions to leave untouched at the end

  • ravel_tensors (bool, default: False) – if True, the unfolded tensors are also flattened

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

Return type:

Array

Returns:

ret – partially unfolded tensor

Array.partial_unfold(self, /, mode=0, skip_begin=1, skip_end=0, ravel_tensors=False, *, out=None)[source]#

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

Parameters:
  • self (Union[Array, NativeArray]) – tensor of shape n_samples x n_1 x n_2 x … x n_i

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

  • skip_begin (Optional[int], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[int], default: 0) – number of dimensions to leave untouched at the end

  • ravel_tensors (Optional[bool], default: False) – if True, the unfolded tensors are also flattened

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

Return type:

Array

Returns:

ret – partially unfolded tensor

Container.partial_unfold(self, /, mode=0, skip_begin=1, skip_end=0, ravel_tensors=False, *, out=None)[source]#

ivy.Container instance method variant of ivy.partial_unfold.

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – tensor of shape n_samples x n_1 x n_2 x … x n_i

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

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[Union[int, Container]], default: 0) – number of dimensions to leave untouched at the end

  • ravel_tensors (Optional[Union[bool, Container]], default: False) – if True, the unfolded tensors are also flattened

  • 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 – partially unfolded tensor