yoyololicon / pytorch-NMF

A pytorch package for non-negative matrix factorization.
https://pytorch-nmf.readthedocs.io/
MIT License
226 stars 24 forks source link

Support Sparse Matrix as Target Matrix #16

Closed yoyololicon closed 3 years ago

yoyololicon commented 3 years ago

This PR add the ability to call fit and sparse_fit when target is a 2-dimensional torch.sparse_coo_tensor. This is only valid on NMF, other class of NMF will throw not implemented error.

codecov-io commented 3 years ago

Codecov Report

Merging #16 (dec2d34) into master (ea4ebcb) will decrease coverage by 5.99%. The diff coverage is 74.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   94.63%   88.63%   -6.00%     
==========================================
  Files           7        7              
  Lines         671      792     +121     
==========================================
+ Hits          635      702      +67     
- Misses         36       90      +54     
Flag Coverage Δ
unittests 88.63% <74.01%> (-6.00%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
torchnmf/nmf.py 84.34% <71.95%> (-11.37%) :arrow_down:
torchnmf/metrics.py 100.00% <100.00%> (ø)
torchnmf/trainer.py 93.75% <100.00%> (+0.11%) :arrow_up:

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 ea4ebcb...dec2d34. Read the comment docs.

yoyololicon commented 3 years ago

Seems that training would become very unstable when using sparse_fit with sparse target and beta < 0, Maybe add extra docstring on sparse_fit to mention that beta = 2 is prefered (the original paper only use euclidean distance), other beta values is not gaurantee to work.