This algorithm implements the Maximum-a-posteriori (MAP) estimation for a GMM
Algorithms have at least one input and one output. All algorithm endpoints are organized in groups. Groups are used by the platform to indicate which inputs and outputs are synchronized together. The first group is automatically synchronized with the channel defined by the block in which the algorithm is deployed.
Endpoint Name | Data Format | Nature |
---|---|---|
features | system/array_2d_floats/1 | Input |
id | system/uint64/1 | Input |
model | tutorial/gmm/1 | Output |
Endpoint Name | Data Format | Nature |
---|---|---|
ubm | tutorial/gmm/1 | Input |
xxxxxxxxxx
import bob
import numpy
from bob.machine import GMMMachine
def gmm_from_data(data):
"""Unmangles a bob.machine.GMMMachine from a BEAT Data object"""
dim_c, dim_d = data.means.shape
gmm = GMMMachine(dim_c, dim_d)
gmm.weights = data.weights
gmm.means = data.means
gmm.variances = data.variances
gmm.variance_thresholds = data.variance_thresholds
return gmm
class Algorithm:
def __init__(self):
self.ubm = None
self.features = []
def process(self, inputs, outputs):
# retrieve the UBM once
if self.ubm is None:
inputs['ubm'].next()
self.ubm = gmm_from_data(inputs['ubm'].data)
# collect all the features for the current template
self.features.append(inputs["features"].data.value)
# adapts the UBM GMM for the template (when all the features have been collected)
if inputs["id"].isDataUnitDone():
model = bob.machine.GMMMachine(self.ubm)
trainer = bob.trainer.MAP_GMMTrainer()
trainer.max_iterations = 1
trainer.set_prior_gmm(self.ubm)
trainer.train(model, numpy.vstack(self.features))
# outputs data
outputs["model"].write({
'weights': model.weights,
'means': model.means,
'variances': model.variances,
'variance_thresholds': model.variance_thresholds,
})
self.features = []
return True
The code for this algorithm in Python
The ruler at 80 columns indicate suggested POSIX line breaks (for readability).
The editor will automatically enlarge to accomodate the entirety of your input
Use keyboard shortcuts for search/replace and faster editing. For example, use Ctrl-F (PC) or Cmd-F (Mac) to search through this box
For a given set of feature vectors and a Gaussian Mixture Models (GMM), this algorithm implements the Maximum-a-posteriori (MAP) estimation (adapting only the means).
Details of MAP estimation can be found in [Reynolds2000]. A very good description on how the MAP estimation works can be found in the Mathematical Monks's YouTube channel.z
This algorithm relies on the Bob library.
The inputs are:
The output, model, is the adapted GMM (MAP adaptation).
[Reynolds2000] | Reynolds, Douglas A., Thomas F. Quatieri, and Robert B. Dunn. "Speaker verification using adapted Gaussian mixture models." Digital signal processing 10.1 (2000): 19-41. |
Updated | Name | Databases/Protocols | Analyzers | |||
---|---|---|---|---|---|---|
tutorial/tutorial/full_ubmgmm/2/mobioMale_gmm_DCT12x8_100G | mobio/1@male | tutorial/eerhter_postperf_iso/1 | ||||
tutorial/tutorial/full_ubmgmm/2/mobioMale_ubmgmm_DCT12x8_100G | mobio/1@male | tutorial/eerhter_postperf_iso/1 | ||||
tutorial/tutorial/full_ubmgmm/2/bancaP_gmm_DCT12x8_100G | banca/1@P | tutorial/eerhter_postperf_iso/1 |
This table shows the number of times this algorithm has been successfully run using the given environment. Note this does not provide sufficient information to evaluate if the algorithm will run when submitted to different conditions.