partial_tucker#

ivy.partial_tucker(x, rank=None, modes=None, /, *, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False)[source]#

Partial tucker decomposition via Higher Order Orthogonal Iteration (HOI)

Decomposes tensor into a Tucker decomposition exclusively along the provided modes.

Parameters:
  • x (Union[Array, NativeArray]) – the input tensor

  • rank (Optional[Sequence[int]], default: None) – size of the core tensor, (len(ranks) == tensor.ndim) if int, the same rank is used for all modes if None, original tensors size will be preserved.

  • modes (Optional[Sequence[int]], default: None) – list of the modes on which to perform the decomposition

  • n_iter_max (Optional[int], default: 100) – maximum number of iteration

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor]], default: 'svd') – {‘svd’, ‘random’}, or TuckerTensor optional if a TuckerTensor is provided, this is used for initialization

  • svd (Optional[Literal['truncated_svd']], default: 'truncated_svd') – str, default is ‘truncated_svd’ function to use to compute the SVD,

  • seed (Optional[int], default: None) – Used to create a random seed distribution when init == ‘random’

  • mask (Optional[Union[Array, NativeArray]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[int], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

  • tol (Optional[float], default: 0.0001) – tolerance: the algorithm stops when the variation in the reconstruction error is less than the tolerance.

  • verbose (Optional[bool], default: False) – if True, different in reconstruction errors are returned at each iteration.

  • return_erros – if True, list of reconstruction errors are returned.

Return type:

Tuple[Array, Sequence[Array]]

Returns:

  • core (ndarray) – core tensor of the Tucker decomposition

  • factors (ndarray list) – list of factors of the Tucker decomposition. with core.shape[i] == (tensor.shape[i], ranks[i]) for i in modes

Array.partial_tucker(self, rank=None, modes=None, /, *, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray]) – the input tensor

  • rank (Optional[Sequence[int]], default: None) – size of the core tensor, (len(ranks) == tensor.ndim) if int, the same rank is used for all modes if None, original tensors size will be preserved.

  • modes (Optional[Sequence[int]], default: None) – list of the modes on which to perform the decomposition

  • n_iter_max (Optional[int], default: 100) – maximum number of iteration

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor]], default: 'svd') – {‘svd’, ‘random’}, or TuckerTensor optional if a TuckerTensor is provided, this is used for initialization

  • svd (Optional[Literal['truncated_svd']], default: 'truncated_svd') – str, default is ‘truncated_svd’ function to use to compute the SVD,

  • seed (Optional[int], default: None) – Used to create a random seed distribution when init == ‘random’

  • mask (Optional[Union[Array, NativeArray]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[int], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

  • tol (Optional[float], default: 0.0001) – tolerance: the algorithm stops when the variation in the reconstruction error is less than the tolerance.

  • verbose (Optional[bool], default: False) – if True, different in reconstruction errors are returned at each iteration.

  • return_erros – if True, list of reconstruction errors are returned.

Return type:

Tuple[Array, Sequence[Array]]

Returns:

  • core (ndarray) – core tensor of the Tucker decomposition

  • factors (ndarray list) – list of factors of the Tucker decomposition. with core.shape[i] == (tensor.shape[i], ranks[i]) for i in modes

Container.partial_tucker(self, rank, modes, /, *, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.partial_tucker. This method simply wraps the function, and so the docstring for ivy.partial_tucker also applies to this method with minimal changes.

Parameters:
  • self (Union[Array, NativeArray, Container]) – input tensor

  • rank (Union[Sequence[int], Container]) – number of components

  • modes (Union[Sequence[int], Container]) – modes to consider in the input tensor

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – initialization scheme for tucker decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – function to use to compute the SVD

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

Return type:

Tuple[Container, Sequence[Container]]

Returns:

  • core – initialized core tensor

  • factors – list of factors