File Exchange

image thumbnail

Practical NMF/NTF with beta divergence

version 1.2 (6.36 KB) by

State-of-the-art algorithms in NMF/NTF using any beta-divergence in an easy to use class



View License

You should prefer the file
for a practical NMF/NTF implementation. I leave this submission because of its use in some other scripts.

Class name : NMF
Implements NMF with any beta divergence, works on data with arbitrary number of channels.
It can work alone, but can also be practical when used with the Signal class (other submission)

Features include :
* Any beta-divergence for cost function. Particular cases of interest are :
beta=2 => Euclidean distance
beta=1 => Generalized KL divergence
beta=0 => Itakura Saito distance

* Any number of components
* Any number of channels (DOA model)
* simulated annealing : it is allowed to provide a cooling scheme for the optimization, through a starting and ending beta for the beta-divergence. This is done by setting beta as a two-elements vector.See A TEMPERING APPROACH FOR ITAKURA-SAITO NON-NEGATIVE MATRIX FACTORIZATION. WITH APPLICATION TO MUSIC TRANSCRIPTION, by Nancy Bertin ICASSP2009

* Divergence weighting : it is possible to take the divergence into account differently, depending of the time-frequency bin. Such an approch was introduced in "Combining Pitch-Based Inference and Non-Negative Spectrogram Factorization in Separating Vocals from Polyphonic Music" by Virtanen, SAPA 2008

* Correlation penalization between rows of H, columns of W, or non-correlation penalization between columns of H. This is done setting the corrHTemporal, corrW and corrHPattern to
positive values. This is inspired from unpublished work by Romain Hennequin.

* Implements exponent stepsize convergence for non convex beta-divergences

* Simple rendering functions, designed to work with the class Signal. Can also work directly on matrices

Typical usage is:
* Along with Signal (for wavfiles manipulations):

s = Signal('linktomy.wav');
n = NMF(s);

* Using matrices directly, let V be a FxTxC matrix
n = NMF(V);

[optional] Now the number of components can be changed:
n.nComponents = 20;

[optional]The beta divergence can be changed:
n.beta = 0; %itakura saito, adequate for spectra

n.beta = 1; % Kullback Leibler, adequate for histograms

n.beta = 2; % Euclidean, adequate for data with gaussian noise

%or, for tempering as suggested by Bertin:
n.beta = [1 0]; %switching from KL to IS during optimization

[optional] If a matrix of weights to apply on the divergence is available, say P (same size as the data):

n.divergenceWeights = P;

[optional] A penalizing factor can be set to the correlations between
* the rows of H:
n.corrHTemporal = 1.5

* the columns of H:
n.corrHPattern = 1.5
* the columns of W:
n.corrW = 1

[optional] The current model can be displayed at each iteration
n.display = 1;

now, performing optimization with, say, 100 iterations:


now, n.W, n.H and n.Q are the NMF parameters. For convienence, functions are available to get the model for a given set of components:

model1=n.getModel(1:10); %for components 1:10

totalModel = n.getModel(); %for all components

Comments and Ratings (3)

It worked! Thank you very much :)

Antoine Liutkus

Hello, yes it is another submission I did that you can find here:


Hi, I wonder if you have the function Signal, I tried to run this but it does not recognize it. And it seems that I can't use wavread.

Thanks in advance.



Made clear that support for this contribution is discontinued and replaced by


changed picture !

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video