pyCP_ALS is the Python implementation of CP-ALS algorithm that was originally introduced in the MATLAB Tensor Toolbox [1,2].
pip install git+https://github.com/MaksimEkin/pyCP_ALS.git
git clone https://github.com/MaksimEkin/pyCP_ALS.git
cd pyCP_ALS
conda create --name pyCP_ALS python=3.8.5
source activate pyCP_ALS
python setup.py install
from pyCP_ALS import CP_ALS
import pickle
data = pickle.load(open("data/toy_tensor.p", "rb"))
nnz_values = data["nnz_values"]
nnz_coords = data["nnz_coords"]
model = CP_ALS(
tol=1e-4,
n_iters=50,
verbose=True,
fixsigns=True,
random_state=42,
)
M = model.fit(
coords=nnz_coords,
values=nnz_values,
rank=2,
Minit="random",
)
See the examples for more.
If you use pyCP_ALS, please cite it.
@MISC{Eren2022pyCP_ALS,
author = {M. E. {Eren}},
title = {{pyCP_ALS}},
year = {2022},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/MaksimEkin/pyCP_ALS}}
}
This work was done as part of Maksim E. Eren's Master's Thesis at the University of Maryland, Baltimore County with the thesis committee members and collaborators Charles Nicholas, Edward Raff, Roberto Yus, Boian S. Alexandrov, and Juston S. Moore. pyCP_ALS was written as part of the RFoT methodology.
Developer test suites are located under tests/
directory. Tests can be ran from this folder using python -m unittest *
.
[1] General software, latest release: Brett W. Bader, Tamara G. Kolda and others, Tensor Toolbox for MATLAB, Version 3.2.1, www.tensortoolbox.org, April 5, 2021.
[2] Sparse, Kruskal, and Tucker tensors: B. W. Bader and T. G. Kolda, Efficient MATLAB Computations with Sparse and Factored Tensors, SIAM J. Scientific Computing, 30(1):205-231, 2007, http://dx.doi.org/10.1137/060676489.