ensign.cp_decomp.cp_als¶
-
cp_als
(sptensor, rank, out_dir=None, seed=0, max_iter=100, stop_tol=1e-05, mem_limit_gb=2, output_init_guess=False, verbose=False, gen_backtrack=False)[source]¶ Performs a CP decomposition using the alternating least squares (ALS) method. [1] [2]
- Parameters
- sptensorSPTensor or str
Tensor to decompose. If sptensor is of type str, it should contain a path to a directory containing an SPTensor or directly to a tensor_data.txt file.
- rankint
Rank of the decomposition.
- out_dirstr
Path to directory where decomposition results will be written. If not set, the decomposition will not be written to disk.
- Returns
- decompCPDecomp
Results of the decomposition.
- Other Parameters
- seedint, optional
Random seed used to initialize decomposition. Default value is
0
.- max_iterint, optional
Maximum iterations before stopping decomposition. Default value is
100
.- stop_tolfloat, optional
Minimum change in fit required for convergence. Default value is
1.0e-5
.- mem_limit_gbint, optional
Maximum memory used during decomposition, in GiB. Default value is
2
.- output_init_guessbool, optional
Write the initial guess of decomposition to
out_dir/input_<mode_id>.txt
Default value isFalse
.- verbosebool, optional
Output verbose decomposition progress to
out_dir/output.txt
Default value isFalse
.- gen_backtrackbool, optional
Output component-wise backtracking information to
out_dir/cpd_backtrack.txt
Default value isFalse
.
- Raises
- Exception
If there is a problem performing the decomposition.
See also
ensign.cp_decomp.CPDecomp
CP decomposition class
ensign.sptensor.SPTensor
Sparse tensor class
References