Diagonal NMF (libnmfd.core.nmfdiag)

libnmfd.core.nmfdiag.nmf_diag(V: ndarray, cost_func: str = 'KLDiv', num_iter: int = 30, init_W: ndarray | None = None, init_H: ndarray | None = None, fix_W: bool = False, cont_polyphony: int = 5, cont_length: int = 10, cont_grid: int = 5, cont_sparsen: Tuple = (1, 1), vis: bool = False) Tuple[ndarray, ndarray][source]

Given a non-negative matrix V, find non-negative matrix factors W and H such that V ~ WH. Possibly also enforce continuity constraints.

References

[1] Lee, DD & Seung, HS. “Algorithms for Non-negative Matrix Factorization”

[2] Sebastian Ewert and Meinard Müller Using score-informed constraints for NMF-based source separation In Proceedings of the IEEE International Conference on Acoustics, Speech, and Signal Processing (ICASSP): 129–132, 2012.

Parameters:
  • V (np.ndarray) – N x M matrix to be factorized

  • cost_func (str, default=KLDiv) – Distance measure which is used for the optimization. Values are ‘EucDist’ for Euclidean, or ‘KLDiv’ for KL-divergence.

  • num_iter (int, default=30) – Number of iterations the algorithm will run.

  • init_W (np.ndarray, default=None) – Initialized W matrix

  • init_H (np.ndarray, default=None) – Initialized H matrix

  • fix_W (bool, default=False) – Set True if templates W should be constant during the update process.

  • cont_polyphony (int, default=5) – TODO: ?

  • cont_length (int, default=10) – Number of templates which should be activated successively for enforced continuity constraints.

  • cont_grid (int, default=5) – Indicates in which iterations of the NMF update procedure the continuity constraints should be enforced.

  • cont_sparsen (Tuple, default=(1, 1)) – TODO: ?

  • vis (bool, default=False) – Set True for visualization.

Returns:
  • W (np.ndarray) – NxK non-negative matrix factor

  • H (np.ndarray) – KxM non-negative matrix factor