Skip to content

Fix svd sign indeterminacy#216

Merged
JeanKossaifi merged 7 commits into
tensorly:mainfrom
merajhashemi:mh-signsvd
Apr 15, 2021
Merged

Fix svd sign indeterminacy#216
JeanKossaifi merged 7 commits into
tensorly:mainfrom
merajhashemi:mh-signsvd

Conversation

@merajhashemi

Copy link
Copy Markdown
Member

This pr builds on @aarmey work in #174 and resolves #74.

@JeanKossaifi

Copy link
Copy Markdown
Member

Great feature that's been on the backlog for a while, thanks @merajhashemi and @aarmey!

Currently this is NumPy specific though and not all backends support array_function so this won't work in all cases. Shall we move it inside the backend class and replace the np. by self.?

@JeanKossaifi JeanKossaifi force-pushed the master branch 2 times, most recently from d45beab to 2aa9834 Compare January 3, 2021 14:51
Base automatically changed from master to main January 22, 2021 13:33
@JeanKossaifi

Copy link
Copy Markdown
Member

Hi @merajhashemi -- are you still working on this?

@codecov

codecov Bot commented Feb 14, 2021

Copy link
Copy Markdown

Codecov Report

Merging #216 (01cbffe) into main (bfda610) will decrease coverage by 0.20%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
- Coverage   87.08%   86.88%   -0.21%     
==========================================
  Files          89       89              
  Lines        4446     4446              
==========================================
- Hits         3872     3863       -9     
- Misses        574      583       +9     
Impacted Files Coverage Δ
tensorly/contrib/decomposition/_tt_cross.py 89.30% <0.00%> (-3.15%) ⬇️
tensorly/decomposition/_cp.py 77.23% <0.00%> (-1.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bfda610...01cbffe. Read the comment docs.

Comment thread tensorly/backend/core.py Outdated

@JeanKossaifi JeanKossaifi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment in the code for the NumPy conversion, otherwise, looks good to me, thanks @merajhashemi!

Comment thread tensorly/backend/core.py Outdated
Comment thread tensorly/backend/core.py Outdated
Comment thread tensorly/backend/core.py Outdated
@JeanKossaifi

Copy link
Copy Markdown
Member

Thanks @merajhashemi - it would be good to have a small unit-test.

Wondering whether it would make sense to unify with cp_sign_flip @cohenjer @aarmey

@aarmey

aarmey commented Mar 5, 2021

Copy link
Copy Markdown
Contributor

I see how they address similar needs, but I don't see a way to unify this with cp_sign_flip, unless I'm missing something.

@cohenjer

cohenjer commented Mar 5, 2021

Copy link
Copy Markdown
Contributor

Unless you want to have a weird, general sign-flip function, I would also keep these separated? But maybe I am simply not understanding what you have in mind @JeanKossaifi

@JeanKossaifi

JeanKossaifi commented Mar 5, 2021

Copy link
Copy Markdown
Member

Was just a thought as SVD can be seen as a 2D CP with weights = diag(S) and factors = [U, V], so it would be possible to resolve the sign ambiguity for all cases. But indeed the way it's done is different enough that a unified function would probably be awkward. Might be best leave the two separate indeed.

@JeanKossaifi JeanKossaifi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just missing a small unit-test and I think it's ready to merge.

@aarmey

aarmey commented Apr 15, 2021

Copy link
Copy Markdown
Contributor

If this is just missing a test, I'm happy to write one as part of #227, since that will likely require some refactoring of the tests as well.

@JeanKossaifi

Copy link
Copy Markdown
Member

Awesome, thanks @aarmey, in that case I'll go ahead and merge!

@JeanKossaifi JeanKossaifi dismissed their stale review April 15, 2021 14:57

Test will be added as part of #227, see #216

@JeanKossaifi JeanKossaifi merged commit de7b5c5 into tensorly:main Apr 15, 2021
@merajhashemi merajhashemi deleted the mh-signsvd branch August 25, 2021 20:13
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

Successfully merging this pull request may close these issues.

Sign indeterminacy of SVD

4 participants