Python API

This section includes information for using the pure Python API of bob.learn.misc.

bob.learn.misc.ztnorm_same_value(vect_a, vect_b)[source]

Computes the matrix of boolean D for the ZT-norm, which indicates where the client ids of the T-Norm models and Z-Norm samples match.

vect_a An (ordered) list of client_id corresponding to the T-Norm models vect_b An (ordered) list of client_id corresponding to the Z-Norm impostor samples

bob.learn.misc.get_config()[source]

Returns a string containing the configuration information.

class bob.learn.misc.EMPCATrainer((object)self[, (float)convergence_threshold[, (int)max_iterations[, (bool)compute_likelihood]]])

Bases: bob.learn.misc._old_library.EMTrainerLinear

This class implements the EM algorithm for a Linear Machine (Probabilistic PCA). See Section 12.2 of Bishop, “Pattern recognition and machine learning”, 2006

__init__( (object)self, (EMPCATrainer)trainer) -> None : Copy constructs an EMPCATrainer

compute_likelihood((EMTrainerLinear)self, (object)machine) → float :

Computes the current log likelihood given the hidden variable distribution (or the sufficient statistics)

compute_likelihood_variable

Indicates whether the log likelihood should be computed during EM or not

convergence_threshold

Convergence threshold

e_step((EMTrainerLinear)self, (object)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

finalize((EMTrainerLinear)self, (object)machine, (object)data) → None :

This method is called at the end of the EM algorithm

initialize((EMTrainerLinear)self, (object)machine, (object)data) → None :

This method is called before the EM algorithm

is_similar_to((EMPCATrainer)self, (EMPCATrainer)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this EMPCATrainer with the ‘other’ one to be approximately the same.

m_step((EMTrainerLinear)self, (object)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

sigma2

The noise sigma2 of the probabilistic model

train((EMTrainerLinear)self, (object)machine, (object)data) → None :

Trains a machine using data

class bob.learn.misc.EMTrainerGMM

Bases: Boost.Python.instance

The base python class for all EM-based trainers.

Raises an exception This class cannot be instantiated from Python

compute_likelihood((EMTrainerGMM)self, (GMMMachine)machine) → float :

Returns the likelihood.

convergence_threshold

Convergence threshold

e_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called after the EM algorithm

initialize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

train((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Train a machine using data

class bob.learn.misc.EMTrainerIVector

Bases: Boost.Python.instance

The base python class for all EM-based trainers.

Raises an exception This class cannot be instantiated from Python

compute_likelihood((EMTrainerIVector)arg1, (IVectorMachine)machine) → float :

Computes the current log likelihood given the hidden variable distribution (or the sufficient statistics)

compute_likelihood_variable

Indicates whether the log likelihood should be computed during EM or not

convergence_threshold

Convergence threshold

e_step((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

finalize((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

This method is called at the end of the EM algorithm

initialize((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Trains a machine using data

class bob.learn.misc.EMTrainerKMeans

Bases: Boost.Python.instance

The base python class for all EM-based trainers.

Raises an exception This class cannot be instantiated from Python

compute_likelihood((EMTrainerKMeans)self, (KMeansMachine)machine) → float :

Returns the average min (square Euclidean) distance

convergence_threshold

Convergence threshold

e_step((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

This method is called after the EM algorithm

initialize((EMTrainerKMeans)arg1, (KMeansMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Train a machine using data

class bob.learn.misc.EMTrainerLinear

Bases: Boost.Python.instance

The base python class for all EM-based trainers.

Raises an exception This class cannot be instantiated from Python

compute_likelihood((EMTrainerLinear)self, (object)machine) → float :

Computes the current log likelihood given the hidden variable distribution (or the sufficient statistics)

compute_likelihood_variable

Indicates whether the log likelihood should be computed during EM or not

convergence_threshold

Convergence threshold

e_step((EMTrainerLinear)self, (object)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

finalize((EMTrainerLinear)self, (object)machine, (object)data) → None :

This method is called at the end of the EM algorithm

initialize((EMTrainerLinear)self, (object)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerLinear)self, (object)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerLinear)self, (object)machine, (object)data) → None :

Trains a machine using data

class bob.learn.misc.EMTrainerPLDA

Bases: Boost.Python.instance

The base python class for all EM/PLDA-based trainers.

Raises an exception This class cannot be instantiated from Python

e_step((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

finalize((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

This method is called at the end of the EM algorithm

initialize((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Trains a PLDABase using data (mu, F, G and sigma are learnt).

class bob.learn.misc.GMMMachine((object)self)

Bases: bob.learn.misc._old_library.MachineDoubleBase

This class implements a multivariate diagonal Gaussian distribution. See Section 2.3.9 of Bishop, “Pattern recognition and machine learning”, 2006

__init__( (object)arg1, (object)arg2) -> object

__init__( (object)self, (GMMMachine)other) -> None :
Creates a GMMMachine from another GMMMachine, using the copy constructor.

__init__( (object)self, (int)n_gaussians, (int)n_inputs) -> None

acc_statistics((GMMMachine)self, (object)x, (GMMStats)stats) → None :

Accumulate the GMM statistics for this sample(s). Inputs are checked.

acc_statistics_((GMMMachine)self, (object)x, (GMMStats)stats) → None :

Accumulate the GMM statistics for this sample(s). Inputs are NOT checked.

dim_c

The number of Gaussian components C

dim_d

The feature dimensionality D

forward((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output.

forward_((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.

is_similar_to((GMMMachine)self, (GMMMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this GMMMachine with the ‘other’ one to be approximately the same.

load((GMMMachine)self, (object)config) → None :

Load from a Configuration

log_likelihood((GMMMachine)self, (object)x, (object)log_weighted_gaussian_likelihoods) → float :
Output the log likelihood of the sample, x, i.e. log(p(x|bob::learn::misc::GMMMachine)). Inputs are checked.
log_likelihood( (GMMMachine)self, (object)x) -> float :
Output the log likelihood of the sample, x, i.e. log(p(x|GMM)). Inputs are checked.
log_likelihood_((GMMMachine)self, (object)x, (object)log_weighted_gaussian_likelihoods) → float :
Output the log likelihood of the sample, x, i.e. log(p(x|bob::learn::misc::GMMMachine)). Inputs are NOT checked.
log_likelihood_( (GMMMachine)self, (object)x) -> float :
Output the log likelihood of the sample, x, i.e. log(p(x|GMM)). Inputs are checked.
mean_supervector

The mean supervector of the GMMMachine (concatenation of the mean vectors of each Gaussian of the GMMMachine

means

The means of the gaussians

resize((GMMMachine)self, (int)n_gaussians, (int)n_inputs) → None :

Reset the input dimensionality, and the number of Gaussian components. Initialises the weights to uniform distribution.

save((GMMMachine)self, (object)config) → None :

Save to a Configuration

set_variance_thresholds((GMMMachine)self, (object)variance_threshold) → None :

Set the variance flooring thresholds in each dimension to the same vector for all Gaussian components if the argument is a 1D numpy arrray, and equal for all Gaussian components and dimensions if the parameter is a scalar.

shape

A tuple that represents the dimensionality of the GMMMachine (n_gaussians, n_inputs).

update_gaussian((GMMMachine)self, (int)i) → Gaussian :

Get the specified Gaussian component. An exception is thrown if i is out of range.

variance_supervector

The variance supervector of the GMMMachine (concatenation of the variance vectors of each Gaussian of the GMMMachine

variance_thresholds

The variance flooring thresholds for each Gaussian in each dimension

variances

The (diagonal) variances of the Gaussians

weights

The weights (also known as “mixing coefficients”)

class bob.learn.misc.GMMStats((object)self)

Bases: Boost.Python.instance

A container for GMM statistics. With respect to Reynolds, “Speaker Verification Using Adapted Gaussian Mixture Models”, DSP, 2000: Eq (8) is n(i) Eq (9) is sumPx(i) / n(i) Eq (10) is sumPxx(i) / n(i)

__init__( (object)arg1, (object)arg2) -> object

__init__( (object)self, (int)n_gaussians, (int)n_inputs) -> None

__init__( (object)self, (GMMStats)other) -> None :
Creates a GMMStats from another GMMStats, using the copy constructor.
init((GMMStats)self) → None :

Resets statistics to zero.

is_similar_to((GMMStats)self, (GMMStats)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this GMMStats with the ‘other’ one to be approximately the same.

load((GMMStats)self, (object)config) → None :

Load from a Configuration

log_likelihood

The accumulated log likelihood of all samples

n

For each Gaussian, the accumulated sum of responsibilities, i.e. the sum of P(gaussian_i|x)

resize((GMMStats)self, (int)n_gaussians, (int)n_inputs) → None :

Allocates space for the statistics and resets to zero.

save((GMMStats)self, (object)config) → None :

Save to a Configuration

sum_px

For each Gaussian, the accumulated sum of responsibility times the sample

sum_pxx

For each Gaussian, the accumulated sum of responsibility times the sample squared

t

The accumulated number of samples

class bob.learn.misc.GMMTrainer

Bases: bob.learn.misc._old_library.EMTrainerGMM

This class implements the E-step of the expectation-maximisation algorithm for a GMM Machine. See Section 9.2.2 of Bishop, “Pattern recognition and machine learning”, 2006

Raises an exception This class cannot be instantiated from Python

compute_likelihood((EMTrainerGMM)self, (GMMMachine)machine) → float :

Returns the likelihood.

convergence_threshold

Convergence threshold

e_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called after the EM algorithm

gmm_statistics

The internal GMM statistics. Useful to parallelize the E-step.

initialize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

train((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Train a machine using data

class bob.learn.misc.Gaussian((object)arg1, (object)arg2)

Bases: bob.learn.misc._old_library.MachineDoubleBase

This class implements a multivariate diagonal Gaussian distribution.

__init__( (object)self) -> None

__init__( (object)self, (int)n_inputs) -> None

__init__( (object)self, (Gaussian)other) -> None

dim_d

Dimensionality of the input feature space

forward((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output.

forward_((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.

is_similar_to((Gaussian)self, (Gaussian)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this Gaussian with the ‘other’ one to be approximately the same.

load((Gaussian)self, (object)config) → None :

Load from a Configuration

log_likelihood((Gaussian)self, (object)sample) → float :

Output the log likelihood of the sample, x. The input size is checked.

log_likelihood_((Gaussian)self, (object)sample) → float :

Output the log likelihood of the sample, x. The input size is NOT checked.

mean

Mean of the Gaussian

resize((Gaussian)self, (int)dim_d) → None :

Set the input dimensionality, reset the mean to zero and the variance to one.

save((Gaussian)self, (object)config) → None :

Save to a Configuration

set_variance_thresholds((Gaussian)self, (float)var_thd) → None :

Set the variance flooring thresholds equal to the given threshold for all the dimensions.

shape

A tuple that represents the dimensionality of the Gaussian (dim_d,).

variance

The diagonal of the (diagonal) covariance matrix

variance_thresholds

The variance flooring thresholds, i.e. the minimum allowed value of variance in each dimension. The variance will be set to this value if an attempt is made to set it to a smaller value.

class bob.learn.misc.ISVBase((object)arg1, (object)arg2)

Bases: bob.learn.misc._old_library.MachineGMMStatsScalarBase

An ISVBase instance can be seen as a container for U and D when performing Joint Factor Analysis (ISV).

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Constructs a new ISVBaseMachine from a configuration file.

__init__( (object)self, (GMMMachine)ubm [, (int)ru=1]) -> None :
Builds a new ISVBase.
__init__( (object)self) -> None :
Constructs a 1 ISVBase instance. You have to set a UBM GMM and resize the U and D subspaces afterwards.
__init__( (object)self, (ISVBase)machine) -> None :
Copy constructs an ISVBase
d

The subspace D for residual variations

dim_c

The number of Gaussian components

dim_cd

The dimensionality of the supervector space

dim_d

The dimensionality of the feature space

dim_ru

The dimensionality of the within-class variations subspace (rank of U)

forward((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

is_similar_to((ISVBase)self, (ISVBase)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this ISVBase with the ‘other’ one to be approximately the same.

load((ISVBase)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

resize((ISVBase)self, (int)ru) → None :

Reset the dimensionality of the subspaces U.

save((ISVBase)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

u

The subspace U for within-class variations

ubm

The UBM GMM attached to this Joint Factor Analysis model

class bob.learn.misc.ISVMachine((object)arg1, (object)arg2)

Bases: bob.learn.misc._old_library.MachineGMMStatsScalarBase

An ISVMachine. An attached ISVBase should be provided for Inter-session Variability Modelling. The ISVMachine carries information about the speaker factors z, whereas a ISVBase carries information about the matrices U and D.

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Constructs a new ISVMachine from a configuration file.

__init__( (object)self) -> None :
Constructs a 1 ISVMachine instance. You have to set a ISVBase afterwards.
__init__( (object)self, (ISVBase)isv_base) -> None :
Builds a new ISVMachine.
__init__( (object)self, (ISVMachine)machine) -> None :
Copy constructs an ISVMachine
dim_c

The number of Gaussian components

dim_cd

The dimensionality of the supervector space

dim_d

The dimensionality of the feature space

dim_ru

The dimensionality of the within-class variations subspace (rank of U)

estimate_ux((ISVMachine)self, (GMMStats)stats, (object)ux) → None :

Estimates Ux (LPT assumption) given GMM statistics.

estimate_x((ISVMachine)self, (GMMStats)stats, (object)x) → None :

Estimates the session offset x (LPT assumption) given GMM statistics.

forward((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

forward_ux((ISVMachine)self, (GMMStats)stats, (object)ux) → float :

Processes the GMM statistics and Ux to return a score.

is_similar_to((ISVMachine)self, (ISVMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this ISVBase with the ‘other’ one to be approximately the same.

isv_base

The ISVBase attached to this machine

load((ISVMachine)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

save((ISVMachine)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

z

The latent variable z of this machine

class bob.learn.misc.ISVTrainer((object)self[, (int)max_iterations=10[, (float)relevance_factor=4.0]])

Bases: Boost.Python.instance

A trainer for Inter-session Variability Modelling (ISV).

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Initializes a new ISVTrainer.

__init__( (object)self, (ISVTrainer)other) -> None :
Copy constructs an ISVTrainer
acc_u_a1

Accumulator updated during the E-step

acc_u_a2

Accumulator updated during the E-step

e_step((ISVTrainer)self, (ISVBase)isv_base, (object)gmm_stats) → None :

Call the e-step procedure.

enrol((ISVTrainer)self, (ISVMachine)isv_machine, (object)gmm_stats, (int)n_iter) → None :

Call the enrolment procedure.

finalize((ISVTrainer)self, (ISVBase)isv_base, (object)gmm_stats) → None :

Call the finalization procedure.

initialize((ISVTrainer)self, (ISVBase)isv_base, (object)gmm_stats) → None :

Call the initialization procedure.

is_similar_to((ISVTrainer)self, (ISVTrainer)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this ISVTrainer with the ‘other’ one to be approximately the same.

m_step((ISVTrainer)self, (ISVBase)isv_base, (object)gmm_stats) → None :

Call the m-step procedure.

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((ISVTrainer)self, (ISVBase)isv_base, (object)gmm_stats) → None :

Call the training procedure.

class bob.learn.misc.IVectorMachine((object)self, (GMMMachine)ubm[, (int)rt=1[, (int)variance_threshold=1e-10]])

Bases: Boost.Python.instance

An IVectorMachine to extract i-vector.

References: [1] ‘Front End Factor Analysis for Speaker Verification’, N. Dehak, P. Kenny, R. Dehak, P. Dumouchel, P. Ouellet, IEEE Transactions on Audio, Speech and Language Processing, 2010, vol. 19, issue 4, pp. 788-798

Builds a new IVectorMachine.

__init__( (object)self) -> None :
Constructs a new empty IVectorMachine.
__init__( (object)arg1, (object)arg2) -> object :
Constructs a new IVectorMachine from a configuration file.
__init__( (object)self, (IVectorMachine)machine) -> None :
Copy constructs an IVectorMachine
dim_c

The number of Gaussian components

dim_cd

The dimensionality of the supervector space

dim_d

The dimensionality of the feature space

dim_rt

The dimensionality of the Total Variability subspace (rank of T)

forward((IVectorMachine)self, (GMMStats)gmmstats, (object)ivector) → None :
Executes the machine on the GMMStats, and updates the ivector array.
forward( (IVectorMachine)self, (GMMStats)gmmstats) -> object :
Executes the machine on the GMMStats. The ivector is allocated an returned.
forward_((IVectorMachine)self, (GMMStats)gmmstats, (object)ivector) → None :

Executes the machine on the GMMStats, and updates the ivector array. NO CHECK is performed.

is_similar_to((IVectorMachine)self, (IVectorMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this IVectorMachine with the ‘other’ one to be approximately the same.

load((IVectorMachine)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

resize((IVectorMachine)self, (int)rt) → None :

Reset the dimensionality of the Total Variability subspace T.

save((IVectorMachine)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

sigma

The residual matrix of the model sigma

t

The subspace T (Total Variability matrix)

ubm

The UBM GMM attached to this Joint Factor Analysis model

variance_threshold

Threshold for the variance contained in sigma

class bob.learn.misc.IVectorTrainer((object)self[, (bool)update_sigma=False[, (float)convergence_threshold=0.001[, (int)max_iterations=10[, (bool)compute_likelihood=False]]]])

Bases: bob.learn.misc._old_library.EMTrainerIVector

An trainer to extract i-vector (i.e. for training the Total Variability matrix)

References: [1] ‘Front End Factor Analysis for Speaker Verification’, N. Dehak, P. Kenny, R. Dehak, P. Dumouchel, P. Ouellet, IEEE Transactions on Audio, Speech and Language Processing, 2010, vol. 19, issue 4, pp. 788-798

Builds a new IVectorTrainer.

__init__( (object)self, (IVectorTrainer)trainer) -> None :
Copy constructs an IVectorTrainer
acc_fnormij_wij

Accumulator updated during the E-step

acc_nij

Accumulator updated during the E-step

acc_nij_wij2

Accumulator updated during the E-step

acc_snormij

Accumulator updated during the E-step

compute_likelihood((EMTrainerIVector)arg1, (IVectorMachine)machine) → float :

Computes the current log likelihood given the hidden variable distribution (or the sufficient statistics)

compute_likelihood_variable

Indicates whether the log likelihood should be computed during EM or not

convergence_threshold

Convergence threshold

e_step((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

finalize((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

This method is called at the end of the EM algorithm

initialize((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

This method is called before the EM algorithm

is_similar_to((IVectorTrainer)self, (IVectorTrainer)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this IVectorTrainer with the ‘other’ one to be approximately the same.

m_step((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerIVector)arg1, (IVectorMachine)machine, (object)data) → None :

Trains a machine using data

class bob.learn.misc.JFABase((object)arg1, (object)arg2)

Bases: bob.learn.misc._old_library.MachineGMMStatsScalarBase

A JFABase instance can be seen as a container for U, V and D when performing Joint Factor Analysis (JFA).

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Constructs a new JFABaseMachine from a configuration file.

__init__( (object)self, (GMMMachine)ubm [, (int)ru=1 [, (int)rv=1]]) -> None :
Builds a new JFABase.
__init__( (object)self) -> None :
Constructs a 1x1 JFABase instance. You have to set a UBM GMM and resize the U, V and D subspaces afterwards.
__init__( (object)self, (JFABase)machine) -> None :
Copy constructs a JFABase
d

The subspace D for residual variations

dim_c

The number of Gaussian components

dim_cd

The dimensionality of the supervector space

dim_d

The dimensionality of the feature space

dim_ru

The dimensionality of the within-class variations subspace (rank of U)

dim_rv

The dimensionality of the between-class variations subspace (rank of V)

forward((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

is_similar_to((JFABase)self, (JFABase)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this JFABase with the ‘other’ one to be approximately the same.

load((JFABase)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

resize((JFABase)self, (int)ru, (int)rv) → None :

Reset the dimensionality of the subspaces U and V.

save((JFABase)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

u

The subspace U for within-class variations

ubm

The UBM GMM attached to this Joint Factor Analysis model

v

The subspace V for between-class variations

class bob.learn.misc.JFAMachine((object)arg1, (object)arg2)

Bases: bob.learn.misc._old_library.MachineGMMStatsScalarBase

A JFAMachine. An attached JFABase should be provided for Joint Factor Analysis. The JFAMachine carries information about the speaker factors y and z, whereas a JFABase carries information about the matrices U, V and D.

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Constructs a new JFAMachine from a configuration file.

__init__( (object)self) -> None :
Constructs a 1x1 JFAMachine instance. You have to set a JFABase afterwards.
__init__( (object)self, (JFABase)jfa_base) -> None :
Builds a new JFAMachine.
__init__( (object)self, (JFAMachine)machine) -> None :
Copy constructs a JFAMachine
dim_c

The number of Gaussian components

dim_cd

The dimensionality of the supervector space

dim_d

The dimensionality of the feature space

dim_ru

The dimensionality of the within-class variations subspace (rank of U)

dim_rv

The dimensionality of the between-class variations subspace (rank of V)

estimate_ux((JFAMachine)self, (GMMStats)stats, (object)ux) → None :

Estimates Ux (LPT assumption) given GMM statistics.

estimate_x((JFAMachine)self, (GMMStats)stats, (object)x) → None :

Estimates the session offset x (LPT assumption) given GMM statistics.

forward((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

forward_ux((JFAMachine)self, (GMMStats)stats, (object)ux) → float :

Processes the GMM statistics and Ux to return a score.

is_similar_to((JFAMachine)self, (JFAMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this JFABase with the ‘other’ one to be approximately the same.

jfa_base

The JFABase attached to this machine

load((JFAMachine)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

save((JFAMachine)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

y

The latent variable y of this machine

z

The latent variable z of this machine

class bob.learn.misc.JFATrainer((object)self[, (int)max_iterations=10])

Bases: Boost.Python.instance

A trainer for Joint Factor Analysis (JFA).

References: [1] ‘Explicit Modelling of Session Variability for Speaker Verification’, R. Vogt, S. Sridharan, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38 [2] ‘Session Variability Modelling for Face Authentication’, C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel, IET Biometrics, 2013

Initializes a new JFATrainer.

__init__( (object)self, (JFATrainer)other) -> None :
Copy constructs an JFATrainer
acc_d_a1

Accumulator updated during the E-step

acc_d_a2

Accumulator updated during the E-step

acc_u_a1

Accumulator updated during the E-step

acc_u_a2

Accumulator updated during the E-step

acc_v_a1

Accumulator updated during the E-step

acc_v_a2

Accumulator updated during the E-step

e_step1((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 1st e-step procedure (for the V subspace).

e_step2((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 2nd e-step procedure (for the U subspace).

e_step3((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 3rd e-step procedure (for the d subspace).

enrol((JFATrainer)self, (JFAMachine)jfa_machine, (object)gmm_stats, (int)n_iter) → None :

Call the enrolment procedure.

finalize1((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 1st finalization procedure (for the V subspace).

finalize2((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 2nd finalization procedure (for the U subspace).

finalize3((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 3rd finalization procedure (for the d subspace).

initialize((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the initialization procedure.

is_similar_to((JFATrainer)self, (JFATrainer)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this JFATrainer with the ‘other’ one to be approximately the same.

m_step1((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 1st m-step procedure (for the V subspace).

m_step2((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 2nd m-step procedure (for the U subspace).

m_step3((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the 3rd m-step procedure (for the d subspace).

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the training procedure.

train_loop((JFATrainer)self, (JFABase)jfa_base, (object)gmm_stats) → None :

Call the training procedure (without the initialization). This will train the three subspaces U, V and d.

class bob.learn.misc.KMeansMachine((object)self)

Bases: bob.learn.misc._old_library.MachineDoubleBase

This class implements a k-means classifier. See Section 9.1 of Bishop, “Pattern recognition and machine learning”, 2006

__init__( (object)arg1, (object)arg2) -> object

__init__( (object)self, (int)n_means, (int)n_inputs) -> None

__init__( (object)self, (KMeansMachine)other) -> None

dim_c

Number of means (k)

dim_d

Number of inputs

forward((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output.

forward_((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.

get_closest_mean((KMeansMachine)self, (object)x) → tuple :

Calculate the index of the mean that is closest (in terms of square Euclidean distance) to the data sample, x

get_distance_from_mean((KMeansMachine)self, (object)x, (int)i) → float :

Return the power of two of the square Euclidean distance of the sample, x, to the i’th mean

get_mean((KMeansMachine)self, (int)i) → object :

Get the i’th mean

get_min_distance((KMeansMachine)self, (object)input) → float :

Output the minimum square Euclidean distance between the input and one of the means

get_variances_and_weights_for_each_cluster((KMeansMachine)self, (object)data) → tuple :

For each mean, find the subset of the samples that is closest to that mean, and calculate 1) the variance of that subset (the cluster variance) 2) the proportion of the samples represented by that subset (the cluster weight)

is_similar_to((KMeansMachine)self, (KMeansMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this KMeansMachine with the ‘other’ one to be approximately the same.

load((KMeansMachine)self, (object)config) → None :

Load from a Configuration

means

The mean vectors

resize((KMeansMachine)self, (int)n_means, (int)n_inputs) → None :

Resize the number of means and inputs

save((KMeansMachine)self, (object)config) → None :

Save to a Configuration

set_mean((KMeansMachine)self, (int)i, (object)mean) → None :

Set the i’th mean

class bob.learn.misc.KMeansTrainer((object)self[, (float)convergence_threshold=0.001[, (int)max_iterations=10[, (bool)compute_likelihood=True[, (initialization_method_type)initialization_method=bob.learn.misc._old_library.initialization_method_type.RANDOM]]]])

Bases: bob.learn.misc._old_library.EMTrainerKMeans

Trains a KMeans machine. This class implements the expectation-maximization algorithm for a k-means machine. See Section 9.1 of Bishop, “Pattern recognition and machine learning”, 2006 It uses a random initialization of the means followed by the expectation-maximization algorithm

KMEANS_PLUS_PLUS = bob.learn.misc._old_library.initialization_method_type.KMEANS_PLUS_PLUS
RANDOM = bob.learn.misc._old_library.initialization_method_type.RANDOM
RANDOM_NO_DUPLICATE = bob.learn.misc._old_library.initialization_method_type.RANDOM_NO_DUPLICATE
average_min_distance

Average min (square Euclidean) distance. Useful to parallelize the E-step.

compute_likelihood((EMTrainerKMeans)self, (KMeansMachine)machine) → float :

Returns the average min (square Euclidean) distance

convergence_threshold

Convergence threshold

e_step((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

This method is called after the EM algorithm

first_order_statistics

The first order statistics. Useful to parallelize the E-step.

initialization_method

The initialization method to generate the initial means.

class initialization_method_type

Bases: Boost.Python.enum

KMEANS_PLUS_PLUS = bob.learn.misc._old_library.initialization_method_type.KMEANS_PLUS_PLUS
RANDOM = bob.learn.misc._old_library.initialization_method_type.RANDOM
RANDOM_NO_DUPLICATE = bob.learn.misc._old_library.initialization_method_type.RANDOM_NO_DUPLICATE
bit_length() → int

Number of bits necessary to represent self in binary. >>> bin(37) ‘0b100101’ >>> (37).bit_length() 6

conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

name
names = {'RANDOM_NO_DUPLICATE': bob.learn.misc._old_library.initialization_method_type.RANDOM_NO_DUPLICATE, 'RANDOM': bob.learn.misc._old_library.initialization_method_type.RANDOM, 'KMEANS_PLUS_PLUS': bob.learn.misc._old_library.initialization_method_type.KMEANS_PLUS_PLUS}
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

values = {0: bob.learn.misc._old_library.initialization_method_type.RANDOM, 1: bob.learn.misc._old_library.initialization_method_type.RANDOM_NO_DUPLICATE, 2: bob.learn.misc._old_library.initialization_method_type.KMEANS_PLUS_PLUS}
KMeansTrainer.initialize((EMTrainerKMeans)arg1, (KMeansMachine)machine, (object)data) → None :

This method is called before the EM algorithm

KMeansTrainer.m_step((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

KMeansTrainer.max_iterations

Max iterations

KMeansTrainer.rng

The Mersenne Twister mt19937 random generator used for the initialization of the means.

KMeansTrainer.train((EMTrainerKMeans)self, (KMeansMachine)machine, (object)data) → None :

Train a machine using data

KMeansTrainer.zeroeth_order_statistics

The zeroeth order statistics. Useful to parallelize the E-step.

class bob.learn.misc.MAP_GMMTrainer((object)self[, (float)relevance_factor=0[, (bool)update_means=True[, (bool)update_variances=False[, (bool)update_weights=False[, (float)responsibilities_threshold=2.220446049250313e-16]]]]])

Bases: bob.learn.misc._old_library.GMMTrainer

This class implements the maximum a posteriori M-step of the expectation-maximisation algorithm for a GMM Machine. The prior parameters are encoded in the form of a GMM (e.g. a universal background model). The EM algorithm thus performs GMM adaptation. See Section 3.4 of Reynolds et al., “Speaker Verification Using Adapted Gaussian Mixture Models”, Digital Signal Processing, 2000. We use a “single adaptation coefficient”, alpha_i, and thus a single relevance factor, r.

compute_likelihood((EMTrainerGMM)self, (GMMMachine)machine) → float :

Returns the likelihood.

convergence_threshold

Convergence threshold

e_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called after the EM algorithm

gmm_statistics

The internal GMM statistics. Useful to parallelize the E-step.

initialize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

set_prior_gmm((MAP_GMMTrainer)self, (GMMMachine)prior_gmm) → bool :

Set the GMM to use as a prior for MAP adaptation. Generally, this is a “universal background model” (UBM), also referred to as a “world model”.

set_t3_map((MAP_GMMTrainer)self, (float)alpha) → None :

Use a torch3-like MAP adaptation rule instead of Reynolds’one.

train((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Train a machine using data

unset_t3_map((MAP_GMMTrainer)self) → None :

Use a Reynolds’ MAP adaptation (rather than torch3-like).

class bob.learn.misc.ML_GMMTrainer((object)self[, (bool)update_means=True[, (bool)update_variances=False[, (bool)update_weights=False[, (float)responsibilities_threshold=2.220446049250313e-16]]]])

Bases: bob.learn.misc._old_library.GMMTrainer

This class implements the maximum likelihood M-step of the expectation-maximisation algorithm for a GMM Machine. See Section 9.2.2 of Bishop, “Pattern recognition and machine learning”, 2006

compute_likelihood((EMTrainerGMM)self, (GMMMachine)machine) → float :

Returns the likelihood.

convergence_threshold

Convergence threshold

e_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the hidden variable distribution (or the sufficient statistics) given the Machine parameters. Also, calculate the average output of the Machine given these parameters. Return the average output of the Machine across the dataset. The EM algorithm will terminate once the change in average_output is less than the convergence_threshold.

finalize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called after the EM algorithm

gmm_statistics

The internal GMM statistics. Useful to parallelize the E-step.

initialize((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

This method is called before the EM algorithm

m_step((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Update the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

train((EMTrainerGMM)self, (GMMMachine)machine, (object)data) → None :

Train a machine using data

class bob.learn.misc.MachineDoubleBase

Bases: Boost.Python.instance

Root class for all Machine<blitz::Array<double,1>, double>

Raises an exception This class cannot be instantiated from Python

forward((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output.

forward_((MachineDoubleBase)self, (object)input) → float :

Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.

class bob.learn.misc.MachineGMMStatsA1DBase

Bases: Boost.Python.instance

Root class for all Machine<bob::learn::misc::GMMStats, blitz::Array<double,1>

Raises an exception This class cannot be instantiated from Python

forward((MachineGMMStatsA1DBase)self, (GMMStats)input, (object)output) → None :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsA1DBase)self, (GMMStats)input, (object)output) → None :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

class bob.learn.misc.MachineGMMStatsScalarBase

Bases: Boost.Python.instance

Root class for all Machine<bob::learn::misc::GMMStats, double>

Raises an exception This class cannot be instantiated from Python

forward((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output.

forward_((MachineGMMStatsScalarBase)self, (GMMStats)input) → float :

Executes the machine on the GMMStats, and returns the (scalar) output. NO CHECK is performed.

class bob.learn.misc.PLDABase((object)self, (int)dim_d, (int)dim_f, (int)dim_g[, (float)variance_flooring=0.0])

Bases: Boost.Python.instance

A PLDABase can be seen as a container for the subspaces F, G, the diagonal covariance matrix sigma (stored as a 1D array) and the mean vector mu when performing Probabilistic Linear Discriminant Analysis (PLDA). PLDA is a probabilistic model that incorporates components describing both between-class and within-class variations. A PLDABase can be shared between several PLDAMachine that contains class-specific information (information about the enrolment samples).

References: 1. ‘A Scalable Formulation of Probabilistic Linear Discriminant Analysis: Applied to Face Recognition’, Laurent El Shafey, Chris McCool, Roy Wallace, Sebastien Marcel, TPAMI‘2013 2. ‘Probabilistic Linear Discriminant Analysis for Inference About Identity’, Prince and Elder, ICCV‘2007. 3. ‘Probabilistic Models for Inference about Identity’, Li, Fu, Mohammed, Elder and Prince, TPAMI‘2012.

Builds a new PLDABase. dim_d is the dimensionality of the input features, dim_f is the dimensionality of the F subspace and dim_g the dimensionality of the G subspace. The variance flooring threshold is the minimum value that the variance sigma can reach, as this diagonal matrix is inverted.

__init__( (object)self) -> None :
Constructs a new empty PLDABase.
__init__( (object)arg1, (object)arg2) -> object :
Constructs a new PLDABase from a configuration file.
__init__( (object)self, (PLDABase)machine) -> None :
Copy constructs a PLDABase
clear_maps((PLDABase)self) → None :

Clear the maps containing the gamma’s as well as the log likelihood constant term for few number of samples. These maps are used to make likelihood computations faster.

compute_gamma((PLDABase)self, (int)a, (object)gamma) → None :

Computes the gamma matrix for the given number of samples. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

compute_log_like_const_term((PLDABase)self, (int)a, (object)gamma) → float :

Computes the log likelihood constant term for the given number of samples.

compute_log_likelihood_point_estimate((PLDABase)self, (object)xij, (object)hi, (object)wij) → float :

Computes the log-likelihood of a sample given the latent variables hi and wij (point estimate rather than Bayesian-like full integration).

dim_d

Dimensionality of the input feature vectors

dim_f

Dimensionality of the F subspace/matrix of the PLDA model

dim_g

Dimensionality of the G subspace/matrix of the PLDA model

f

The subspace/matrix F of the PLDA model

g

The subspace/matrix G of the PLDA model

get_add_gamma((PLDABase)self, (int)a) → numpy.ndarray :

Computes the gamma matrix for the given number of samples. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

get_add_log_like_const_term((PLDABase)self, (int)a) → float :

Computes the log likelihood constant term for the given number of samples, and adds it to the machine (as well as gamma), if it does not already exist.

get_gamma((PLDABase)self, (int)a) → numpy.ndarray :

Returns the gamma matrix for the given number of samples if it has already been put in cache. Throws an exception otherwise. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

get_log_like_const_term((PLDABase)self, (int)a) → float :

Returns the log likelihood constant term for the given number of samples if it has already been put in cache. Throws an exception otherwise.

has_gamma((PLDABase)self, (int)a) → bool :

Tells if the gamma matrix for the given number of samples has already been computed. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

has_log_like_const_term((PLDABase)self, (int)a) → bool :

Tells if the log likelihood constant term for the given number of samples has already been computed.

is_similar_to((PLDABase)self, (PLDABase)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this PLDABase with the ‘other’ one to be approximately the same.

load((PLDABase)self, (object)config) → None :

Loads the configuration parameters from a configuration file.

mu

The mean vector mu of the PLDA model

resize((PLDABase)self, (int)dim_d, (int)dim_f, (int)dim_g) → None :

Resizes the dimensionality of the PLDA model. Paramaters mu, F, G and sigma are reinitialized.

save((PLDABase)self, (object)config) → None :

Saves the configuration parameters to a configuration file.

sigma

The diagonal covariance matrix (represented by a 1D numpy array) sigma of the PLDA model

variance_threshold

The variance flooring threshold, i.e. the minimum allowed value of variance (sigma) in each dimension. The variance sigma will be set to this value if an attempt is made to set it to a smaller value.

class bob.learn.misc.PLDAMachine((object)self, (PLDABase)plda_base)

Bases: Boost.Python.instance

A PLDAMachine contains class-specific information (from the enrolment samples) when performing Probabilistic Linear Discriminant Analysis (PLDA). It should be attached to a PLDABase that contains information such as the subspaces F and G.

References: 1. ‘A Scalable Formulation of Probabilistic Linear Discriminant Analysis: Applied to Face Recognition’, Laurent El Shafey, Chris McCool, Roy Wallace, Sebastien Marcel, TPAMI‘2013 2. ‘Probabilistic Linear Discriminant Analysis for Inference About Identity’, Prince and Elder, ICCV‘2007. 3. ‘Probabilistic Models for Inference about Identity’, Li, Fu, Mohammed, Elder and Prince, TPAMI‘2012.

Builds a new PLDAMachine. An attached PLDABase should be provided, that can be shared by several PLDAMachine.

__init__( (object)self) -> None :
Constructs a new empty (invalid) PLDAMachine. A PLDABase should then be set using the ‘plda_base’ attribute of this object.
__init__( (object)arg1, (object)arg2, (PLDABase)arg3) -> object :
Constructs a new PLDAMachine from a configuration file (and a PLDABase object).
__init__( (object)self, (PLDAMachine)machine) -> None :
Copy constructs a PLDAMachine
clear_maps((PLDAMachine)self) → None :

Clears the maps containing the gamma’s as well as the log likelihood constant term for few number of samples. These maps are used to make likelihood computations faster.

compute_log_likelihood((PLDAMachine)self, (object)sample[, (bool)use_enrolled_samples=True]) → float :

Computes the log-likelihood considering only the probe sample(s) or jointly the probe sample(s) and the enrolled samples.

dim_d

Dimensionality of the input feature vectors

dim_f

Dimensionality of the F subspace/matrix of the PLDA model

dim_g

Dimensionality of the G subspace/matrix of the PLDA model

forward((PLDAMachine)self, (object)sample) → float :

Processes a sample and returns a log-likelihood ratio score.

get_add_gamma((PLDAMachine)self, (int)a) → numpy.ndarray :

Computes the gamma matrix for the given number of samples. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

get_add_log_like_const_term((PLDAMachine)self, (int)a) → float :

Computes the log likelihood constant term for the given number of samples, and adds it to the machine (as well as gamma), if it does not already exist.

get_gamma((PLDAMachine)self, (int)a) → numpy.ndarray :

Returns the gamma matrix for the given number of samples if it has already been put in cache. Throws an exception otherwise. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

get_log_like_const_term((PLDAMachine)self, (int)a) → float :

Returns the log likelihood constant term for the given number of samples if it has already been put in cache. Throws an exception otherwise.

has_gamma((PLDAMachine)self, (int)a) → bool :

Tells if the gamma matrix for the given number of samples has already been computed. (gamma = inverse(I+a.F^T.beta.F), please check the documentation/source code for more details.

has_log_like_const_term((PLDAMachine)self, (int)a) → bool :

Tells if the log likelihood constant term for the given number of samples has already been computed.

is_similar_to((PLDAMachine)self, (PLDAMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this PLDAMachine with the ‘other’ one to be approximately the same.

load((PLDAMachine)self, (object)config) → None :

Loads the configuration parameters from a configuration file. The PLDABase will not be loaded, and has to be set manually using the ‘plda_base’ attribute.

log_likelihood
n_samples

Number of enrolled samples

plda_base
save((PLDAMachine)self, (object)config) → None :

Saves the configuration parameters to a configuration file. The PLDABase will not be saved, and has to be saved separately, as it can be shared by several PLDAMachines.

w_sum_xit_beta_xi
weighted_sum
class bob.learn.misc.PLDATrainer((object)self[, (int)max_iterations=100[, (bool)use_sum_second_order=True]])

Bases: bob.learn.misc._old_library.EMTrainerPLDA

A trainer for Probabilistic Linear Discriminant Analysis (PLDA). The train() method will learn the mu, F, G and Sigma of the model, whereas the enrol() method, will store model information about the enrolment samples for a specific class.

References: 1. ‘A Scalable Formulation of Probabilistic Linear Discriminant Analysis: Applied to Face Recognition’, Laurent El Shafey, Chris McCool, Roy Wallace, Sebastien Marcel, TPAMI‘2013 2. ‘Probabilistic Linear Discriminant Analysis for Inference About Identity’, Prince and Elder, ICCV‘2007. 3. ‘Probabilistic Models for Inference about Identity’, Li, Fu, Mohammed, Elder and Prince, TPAMI‘2012.

Initializes a new PLDATrainer.

__init__( (object)self, (PLDATrainer)trainer) -> None :
Copy constructs a PLDATrainer
BETWEEN_SCATTER = bob.learn.misc._old_library.init_f_method.BETWEEN_SCATTER
CONSTANT = bob.learn.misc._old_library.init_sigma_method.CONSTANT
RANDOM_F = bob.learn.misc._old_library.init_f_method.RANDOM_F
RANDOM_G = bob.learn.misc._old_library.init_g_method.RANDOM_G
RANDOM_SIGMA = bob.learn.misc._old_library.init_sigma_method.RANDOM_SIGMA
VARIANCE_DATA = bob.learn.misc._old_library.init_sigma_method.VARIANCE_DATA
VARIANCE_G = bob.learn.misc._old_library.init_sigma_method.VARIANCE_G
WITHIN_SCATTER = bob.learn.misc._old_library.init_g_method.WITHIN_SCATTER
e_step((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Updates the hidden variable distribution (or the sufficient statistics) given the Machine parameters.

enrol((PLDATrainer)self, (PLDAMachine)plda_machine, (object)data) → None :

Enrol a class-specific model (PLDAMachine) given a set of enrolment samples.

finalize((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

This method is called at the end of the EM algorithm

init_f_method

The method used for the initialization of F.

init_f_ratio

The ratio used for the initialization of F.

init_g_method

The method used for the initialization of G.

init_g_ratio

The ratio used for the initialization of G.

init_sigma_method

The method used for the initialization of sigma.

init_sigma_ratio

The ratio used for the initialization of sigma.

initialize((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

This method is called before the EM algorithm

is_similar_to((PLDATrainer)self, (PLDATrainer)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :

Compares this PLDATrainer with the ‘other’ one to be approximately the same.

m_step((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Updates the Machine parameters given the hidden variable distribution (or the sufficient statistics)

max_iterations

Max iterations

rng

The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.

train((EMTrainerPLDA)self, (PLDABase)machine, (object)data) → None :

Trains a PLDABase using data (mu, F, G and sigma are learnt).

use_sum_second_order

Tells whether the second order statistics are stored during the training procedure, or only their sum.

z_first_order
z_second_order
z_second_order_sum
bob.learn.misc.linear_scoring((object)models, (object)ubm_mean, (object)ubm_variance, (object)test_stats[, (object)test_channelOffset[, (bool)frame_length_normalisation]]) → object :

Compute a matrix of scores using linear scoring. Return a 2D matrix of scores, scores[m, s] is the score for model m against statistics s

Warning Each GMM must have the same size.

models – list of mean supervectors for the client models ubm_mean – mean supervector for the world model ubm_variance – variance supervector for the world model test_stats – list of accumulate statistics for each test trial test_channelOffset – frame_length_normlisation – perform a normalisation by the number of feature vectors

linear_scoring( (object)models, (GMMMachine)ubm, (object)test_stats [, (object)test_channel_offset [, (bool)frame_length_normalisation]]) -> object :

Compute a matrix of scores using linear scoring. Return a 2D matrix of scores, scores[m, s] is the score for model m against statistics s

Warning Each GMM must have the same size.

models – list of client models ubm – world model test_stats – list of accumulate statistics for each test trial test_channel_offset – frame_length_normlisation – perform a normalisation by the number of feature vectors

linear_scoring( (object)model, (object)ubm_mean, (object)ubm_variance, (GMMStats)test_stats, (object)test_channelOffset [, (bool)frame_length_normalisation]) -> float :

Compute a score using linear scoring.

model – mean supervectors for the client model ubm_mean – mean supervector for the world model ubm_variance – variance supervector for the world model test_stats – accumulate statistics for each test trial test_channelOffset – frame_length_normlisation – perform a normalisation by the number of feature vectors

bob.learn.misc.tnorm((object)rawscores_probes_vs_models, (object)rawscores_probes_vs_tmodels) → object :

Normalise raw scores with T-Norm.

bob.learn.misc.znorm((object)rawscores_probes_vs_models, (object)rawscores_zprobes_vs_models) → object :

Normalise raw scores with Z-Norm.

bob.learn.misc.ztnorm((object)rawscores_probes_vs_models, (object)rawscores_zprobes_vs_models, (object)rawscores_probes_vs_tmodels, (object)rawscores_zprobes_vs_tmodels, (object)mask_zprobes_vs_tmodels_istruetrial) → object :
Normalise raw scores with ZT-Norm
ztnorm( (object)rawscores_probes_vs_models, (object)rawscores_zprobes_vs_models, (object)rawscores_probes_vs_tmodels, (object)rawscores_zprobes_vs_tmodels) -> object :
Normalise raw scores with ZT-Norm. Assume that znorm and tnorm have no common subject id.

Previous topic

User guide

This Page