svd_flip#

ivy.svd_flip(U, V, /, u_based_decision=True)[source]#

Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. This function is borrowed from scikit- learn/utils/extmath.py.

Parameters:
  • U (Union[Array, NativeArray]) – left singular matrix output of SVD

  • V (Union[Array, NativeArray]) – right singular matrix output of SVD

  • u_based_decision (Optional[bool], default: True) – If True, use the columns of u as the basis for sign flipping. Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent.

Return type:

Tuple[Array, Array]

Returns:

u_adjusted, v_adjusted (arrays with the same dimensions as the input.)

Array.svd_flip(self, V, /, u_based_decision=True)[source]#

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

Parameters:
  • self (Union[Array, NativeArray]) – left singular matrix output of SVD

  • V (Union[Array, NativeArray]) – right singular matrix output of SVD

  • u_based_decision (Optional[bool], default: True) – If True, use the columns of u as the basis for sign flipping. Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent.

Return type:

Tuple[Array, Array]

Returns:

u_adjusted, v_adjusted (arrays with the same dimensions as the input.)

Container.svd_flip(self, V, /, u_based_decision=True, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – left singular matrix output of SVD

  • V (Union[Array, NativeArray, Container]) – right singular matrix output of SVD

  • u_based_decision (Optional[Union[bool, Container]], default: True) – If True, use the columns of u as the basis for sign flipping. Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent.

Return type:

Tuple[Container, Container]

Returns:

u_adjusted, v_adjusted (container with the same dimensions as the input.)