Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosvd fails for sptensor when using full rank along a mode #14

Open
jackkamm opened this issue Jul 25, 2015 · 2 comments
Open

hosvd fails for sptensor when using full rank along a mode #14

jackkamm opened this issue Jul 25, 2015 · 2 comments

Comments

@jackkamm
Copy link

Hi there, nice package.

I'd like to compute the full hosvd of a large sparse tensor. I thought I could use the method tucker.hosvd, but it breaks for me.

Here is a small example:

T = sptensor(([0,1,2], [0,0,2], [0,2,0]), (1.0,2.0,3.0), (3,3,3))
sktensor.tucker.hosvd(T, (3,3,3))

which results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jackkamm/.local/lib/python2.7/site-packages/scikit_tensor-0.1-py2.7.egg/sktensor/tucker.py", line 132, in hosvd
    U[d] = array(nvecs(X, d, rank[d]), dtype=dtype)
  File "/Users/jackkamm/.local/lib/python2.7/site-packages/scikit_tensor-0.1-py2.7.egg/sktensor/core.py", line 283, in nvecs
    _, U = eigsh(Y, rank, which='LM')
  File "/Users/jackkamm/anaconda/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py", line 1487, in eigsh
    raise ValueError("k must be between 1 and ndim(A)-1")
ValueError: k must be between 1 and ndim(A)-1

The issue appears to be, if T is a sptensor, then scipy.sparse.linalg.eigsh will be used to get the eigendecomposition of the matrix unfolding. However, eigsh cannot return all eigenvalues. And while eigsh works well for the first few eigenvalues of a large sparse matrix, it appears to works poorly for the lower eigenvalues. (or at least, that is what I have read online about the Implicitly Restarted Lanczos Method, which eigsh uses)

I'd prefer not to convert the sptensor to a dtensor, since the tensor dimensions are quite large.

For now I will just use my own code to get the full hosvd. But I would prefer to have the default of nvecs and hosvd always use scipy.linalg.eigh, with a user option to use eigsh instead. If you like, I can submit a PR with this change.

@jackkamm jackkamm changed the title hosvd fails for sptensor when using full rank along a dimension hosvd fails for sptensor when using full rank along a mode Jul 25, 2015
@jtliso
Copy link

jtliso commented Nov 3, 2017

@jackkamm I know this is old, but I just saw this issue and am having the same problem. Do you remember if you solved this problem? If so, could you point me to your solution?

@simo1000k
Copy link

@jtliso I have the same problem. Can you help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants