Repository navigation
Conversation
SVD-initialized PARAFAC on sparse tensors failed because the sparse backend lacked argmax (axis) and index_update. Also validate that the imported `sparse` module provides the required functions so a wrong/shadowing module gives a clear ImportError instead of a bare AttributeError.
Member
|
Looks good to me, thank you! |
antonsoo
reviewed
Oct 29, 2026
antonsoo
left a comment
Contributor
There was a problem hiding this comment.
Tested 85fd172 on CPU with PyData sparse 0.19.2: pytest tensorly/contrib/sparse tensorly/tenalg -q gives 291 passed.
Also checked reconstructed values beyond the new shape test: six sparse rank-1/2/3 tensors in float32/float64 match dense PARAFAC, and rank-4 PARAFAC of the Zachary karate-club adjacency matrix matches NumPy's truncated SVD (residual norm 7.346444141705379 versus 7.346444141705378). All seven decompositions fail on the parent a4f8954 with the missing argmax(axis=...) error. Twelve argmax comparisons covering implicit zeros, ties and negative axes also match NumPy on this head. No issue found in these paths.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #446.
argmax(withaxis) to the numpy.sparse backend, returning dense indices. Previouslyparafac(..., init="svd")on a sparse tensor failed withTypeError: Backend.argmax() got an unexpected keyword argument 'axis'insvd_flip.index_updatefor COO arrays (immutable), needed by the SVD init after the above.sparsemodule provides the functions the backend registers, and has__version__. A wrong or shadowingsparsemodule now raises a clearImportErrorinstead of a bareAttributeError(the symptom reported in parafac decomposition when registering sparse backend #446).argmax.pytest tensorly/contrib/sparse tensorly/tenalg: 291 passed (sparse 0.19.2).