initialize_tucker#

ivy.initialize_tucker(x, rank, modes, /, *, init='svd', seed=None, svd='truncated_svd', non_negative=False, mask=None, svd_mask_repeats=5)[source]#

Initialize core and factors used in tucker. The type of initialization is set using init. If init == ‘random’ then initialize factor matrices using random_state. If init == ‘svd’ then initialize the m`th factor matrix using the `rank left singular vectors of the `m`th unfolding of the input tensor.

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

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

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

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

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

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

  • non_negative (Optional[bool], default: False) – if True, non-negative factors are returned

  • 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

Return type:

Tuple[Array, Sequence[Array]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

Array.initialize_tucker(self, rank, modes, /, *, init='svd', seed=None, svd='truncated_svd', non_negative=False, mask=None, svd_mask_repeats=5)[source]#

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

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

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

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

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

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

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

  • non_negative (Optional[bool], default: False) – if True, non-negative factors are returned

  • 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

Return type:

Tuple[Array, Sequence[Array]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

Container.initialize_tucker(self, rank, modes, /, *, init='svd', seed=None, svd='truncated_svd', non_negative=False, mask=None, svd_mask_repeats=5, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

  • non_negative (Optional[Union[bool, Container]], default: False) – if True, non-negative factors are returned

  • 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