pyttb.tucker_als

Tucker decomposition via Alternating Least Squares.

pyttb.tucker_als.tucker_als(input_tensor: tensor, rank: int | float | Iterable[int] | Iterable[float] | ndarray, stoptol: float = 1e-4, maxiters: int = 1000, dimorder: int | float | Iterable[int] | Iterable[float] | ndarray | None = None, init: Literal['random'] | Literal['nvecs'] | ktensor = 'random', printitn: int = 1) Tuple[ttensor, ttensor, Dict][source]

Compute Tucker decomposition with alternating least squares.

Parameters:
  • input_tensor – Tensor to decompose.

  • rank – Rank of the decomposition(s)

  • stoptol – Tolerance used for termination - when the change in the fitness function in successive iterations drops below this value, the iterations terminate

  • dimorder – Order to loop through dimensions (default: [range(tensor.ndims)])

  • maxiters – Maximum number of iterations

  • init

    Initial guess (default: “random”)
    • “random”: initialize using a pyttb.ttensor with values chosen from

      a Normal distribution with mean 0 and standard deviation 1

    • “nvecs”: initialize factor matrices of a pyttb.ttensor using the

      eigenvectors of the outer product of the matricized input tensor

    • pyttb.ttensor: initialize using a specific pyttb.ttensor

      as input - must be the same shape as the input tensor and have the same rank as the input rank

  • printitn – Number of iterations to perform before printing iteration status: 0 for no status printing

Returns:

  • M – Resulting ttensor from Tucker-ALS factorization

  • Minit – Initial guess

  • output – Information about the computation. Dictionary keys:

    • params : tuple of (stoptol, maxiters, printitn, dimorder)

    • iters: number of iterations performed

    • normresidual: norm of the difference between the input tensor and ktensor

      factorization

    • fit: value of the fitness function (fraction of tensor data explained by

      the model)