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

It appears that partial_unfold works using sparse tensors, but it is not clear in the documentation #520

Open
mdarmstr opened this issue Aug 9, 2023 · 0 comments

Comments

@mdarmstr
Copy link

mdarmstr commented Aug 9, 2023

Creating a sparse tensor using the sparse backend. Works as expected with unfold, and with partial_unfold.

import numpy as np
import sparse
from tensorly.contrib.sparse import tensor, unfold
from tensorly.base import partial_unfold

X = sparse.COO(np.arange(1152).reshape((24,3,2,8)))
X = sparse.COO(X.coords, X.data, shape=(100, 100, 100, 100))
X = tensor(X, dtype='float')
print(unfold(X, 2)) # mode-1 unfolding, from tensorly.contrib.sparse
print(partial_unfold(X,0,1,0))

output:
<COO: shape=(100, 1000000), dtype=float64, nnz=1151, fill_value=0.0>
<COO: shape=(100, 100, 10000), dtype=float64, nnz=1151, fill_value=0.0>

Linux-5.19.0-46-generic-x86_64-with-glibc2.35Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
NumPy 1.24.4
SciPy 1.11.1
TensorLy 0.8.1

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

1 participant