Skip to content

Using the GMM Specializer

egonina edited this page Dec 8, 2011 · 26 revisions

Here we describe how to use the GMM specializer in your Python code and give examples. Please refer to our HotPar'11 and ASRU'11 papers for details on the specializer and the speaker diarization example respectively. Our specializer uses numpy to store and manipulate arrays.

Importing the specializer

After installing Asp and the GMM specializer, you need to import it in your Python script like so:

from em import *

Creating the GMM object

Creating a GMM object is just like creating an object of any class in Python. You can either create an empty GMM object, specifying its dimensions (M = number of components, D = dimension):

gmm = GMM(M, D)

The parameters will be initialized randomly from the data when the train() function is called (see below). GMM can also be initialized with existing parameters, like so:

gmm = GMM(M, D, means, vars, weights)

Where means, vars and weights are numpy arrays. Note: when training the GMM, these parameters will get overwritten by new parameters after training, if you are using parameters from a different GMM, make sure to make a copy of the parameters first and pass that to the GMM constructor.

GMM Training

To train the GMM object on a set of observations, use the train() function:

lkld = gmm.train(data)

Where data is an N by D numpy array of observation vectors (N vectors, each of D dimensions). It returns the likelihood of the trained GMM fitting the data.

Computing likelihood given the trained GMM

To compute the (log)likelihood of the trained GMM on a new set of observations use the score() function:

log_lklds = gmm.score(data)

Where data is an N by D numpy array.

Clone this wiki locally