-
Notifications
You must be signed in to change notification settings - Fork 1
Using the GMM Specializer
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.
After installing Asp and the GMM specializer, you need to import it in your Python script like so:
from em import *
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.
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.
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.