This algorithm implements the Maximum-a-posteriori (MAP) estimation

This algorithm is a legacy one. The API has changed since its implementation. New versions and forks will need to be updated.

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.

Group: main

Endpoint Name Data Format Nature
features system/array_2d_floats/1 Input
id system/text/1 Input
model tutorial/gmm/1 Output

Unnamed group

Endpoint Name Data Format Nature
ubm tutorial/gmm/1 Input
xxxxxxxxxx
59
 
1
import bob
2
import numpy
3
from bob.machine import GMMMachine
4
5
6
7
def gmm_from_data(data):
8
    """Unmangles a bob.machine.GMMMachine from a BEAT Data object"""
9
10
    dim_c, dim_d = data.means.shape
11
    gmm = GMMMachine(dim_c, dim_d)
12
    gmm.weights = data.weights
13
    gmm.means = data.means
14
    gmm.variances = data.variances
15
    gmm.variance_thresholds = data.variance_thresholds
16
    return gmm
17
18
19
20
class Algorithm:
21
22
    def __init__(self):
23
        self.ubm      = None
24
        self.features = []
25
26
27
    def process(self, inputs, outputs):
28
29
        # retrieve the UBM once
30
        if self.ubm is None:
31
            inputs['ubm'].next()
32
            self.ubm = gmm_from_data(inputs['ubm'].data)
33
34
35
        # collect all the features for the current template
36
        self.features.append(inputs["features"].data.value)
37
38
39
        # adapts the UBM GMM for the template (when all the features have been collected)
40
        if inputs["id"].isDataUnitDone():
41
            model = bob.machine.GMMMachine(self.ubm)
42
43
            trainer = bob.trainer.MAP_GMMTrainer(4)
44
            trainer.max_iterations = 1
45
            trainer.set_prior_gmm(self.ubm)
46
            trainer.train(model, numpy.vstack(self.features))
47
48
            # outputs data
49
            outputs["model"].write({
50
                'weights':              model.weights,
51
                'means':                model.means,
52
                'variances':            model.variances,
53
                'variance_thresholds':  model.variance_thresholds,
54
            })
55
56
            self.features = []
57
58
        return True
59

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 the paper: 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. 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.

No experiments are using this algorithm.
Created with Raphaël 2.1.2[compare]elie_khoury/gmm_projection/1elie_khoury/gmm_projection/2Aug292014Sep6
This algorithm was never executed.
Terms of Service | Contact Information | BEAT platform version 2.2.1b0 | © Idiap Research Institute - 2013-2025