mnick / scikit-tensor

Python library for multilinear algebra and tensor factorizations
GNU General Public License v3.0
401 stars 113 forks source link

`cp_als` fails with `sptensor`---intended behavior? #13

Open ynadji opened 9 years ago

ynadji commented 9 years ago

It's possible this is intended behavior. If so, my apologies, and feel free to close the issue. The input tensor I am using can be downloaded as a pickle file.

>>> import pickle
>>> with open('test-S.pkl', 'rb') as f:
...     S = pickle.load(f)
... 
>>> P, fit, itr, exectimes = cp_als(S, 3, init='random')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yacin/work/tensors/venv/local/lib/python2.7/site-packages/sktensor/cp.py", line 143, in als
    Unew = X.uttkrp(U, n)
  File "/home/yacin/work/tensors/venv/local/lib/python2.7/site-packages/sktensor/sptensor.py", line 224, in uttkrp
    TZ = self.ttv(Z, mode, without=True)
  File "/home/yacin/work/tensors/venv/local/lib/python2.7/site-packages/sktensor/core.py", line 127, in ttv
    return self._ttv_compute(v, dims, vidx, remdims)
  File "/home/yacin/work/tensors/venv/local/lib/python2.7/site-packages/sktensor/sptensor.py", line 159, in _ttv_compute
    nvals = nvals * w[idx]
IndexError: too many indices for array
>>> P, fit, itr, exectimes = cp_als(dtensor(S.toarray()), 3, init='random')
>>>