pyttb.hosvd
Higher Order SVD Implementation.
- pyttb.hosvd.hosvd(input_tensor: tensor, tol: float, verbosity: float = 1, dimorder: int | float | Iterable[int] | Iterable[float] | ndarray | None = None, sequential: bool = True, ranks: int | float | Iterable[int] | Iterable[float] | ndarray | None = None) ttensor [source]
Compute sequentially-truncated higher-order SVD (Tucker).
Computes a Tucker decomposition with relative error specified by tol, i.e., it computes a ttensor T such that ||X-T||/||X|| <= tol.
- Parameters:
input_tensor – Tensor to factor
tol – Relative error to stop at
verbosity – Print level
dimorder – Order to loop through dimensions
sequential – Use sequentially-truncated version
ranks – Specify ranks to consider rather than computing
Example
>>> data = np.array([[29, 39.0], [63.0, 85.0]]) >>> tol = 1e-4 >>> disable_printing = -1 >>> tensorInstance = ttb.tensor(data) >>> result = hosvd(tensorInstance, tol, verbosity=disable_printing) >>> ((result.full() - tensorInstance).norm() / tensorInstance.norm()) < tol True