tucker#

ivy.tucker(x, rank=None, /, *, fixed_factors=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]#

Tucker decomposition via Higher Order Orthogonal Iteration (HOI)

Decomposes tensor into a Tucker decomposition: tensor = [| core; factors[0], ...factors[-1] |] [1]_

Parameters:
  • x (Union[Array, NativeArray]) – 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

  • fixed_factors (Optional[Sequence[int]], default: None) – if not None, list of modes for which to keep the factors fixed. Only valid if a Tucker tensor is provided as init.

  • 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_errors (Optional[bool], default: False) – Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

Returns:

ivy.TuckerTensor or ivy.TuckerTensor and list of reconstruction errors if return_erros is True.

References

Array.tucker(self, rank=None, /, *, fixed_factors=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.tucker. This method simply wraps the function, and so the docstring for ivy.tucker also applies to this method with minimal changes.

Parameters:
  • x – 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

  • fixed_factors (Optional[Sequence[int]], default: None) – if not None, list of modes for which to keep the factors fixed. Only valid if a Tucker tensor is provided as init.

  • 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_errors (Optional[bool], default: False) – Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

Returns:

  • ivy.TuckerTensor or ivy.TuckerTensor and

  • list of reconstruction errors if return_erros is True.

References

SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.

Container.tucker(self, rank, /, *, fixed_factors=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, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x – input tensor

  • rank (Union[Sequence[int], Container]) – size of the core tensor, (len(ranks) == tensor.ndim) if int, the same rank is used for all modes

  • fixed_factors (Optional[Union[Sequence[int], Container]], default: None) – if not None, list of modes for which to keep the factors fixed. Only valid if a Tucker tensor is provided as init.

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

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

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

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

  • 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

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

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

  • return_errors (Optional[Union[bool, Container]], default: False) – Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

Return type:

Tuple[Container, Sequence[Container]]

Returns:

Container of ivy.TuckerTensors or ivy.TuckerTensors and

container of reconstruction errors if return_errors is True.

References

SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.