Python API¶
This section includes information for using the pure Python API of
bob.learn.em.
Classes¶
Trainers¶
Trains a KMeans clustering k-means.This class implements the expectation-maximization algorithm for a k-means.See Section 9.1 of Bishop, "Pattern recognition and machine learning", 2006It uses a random initialization of the means followed by the expectation-maximization algorithm |
|
This class implements the maximum likelihood M-step (MLE) of the expectation-maximisation algorithm for a GMM Machine. |
|
This class implements the maximum a posteriori (MAP) M-step of the expectation-maximization algorithm for a GMM Machine. |
|
ISVTrainerTrain Intersession varibility modeling ISV. |
|
Trains a Joint Factor Analysis (JFA) on top of GMMs |
|
IVectorTrainerTrains the Total Variability subspace \($T$\) to generate iVectors. |
|
This class can be used to train the \(F\), \(G\) and \(\Sigma\) matrices and the mean vector \(\mu\) of a PLDA model.References: [ElShafey2014] [PrinceElder2007] [LiFu2012] |
|
Trains a |
Machines¶
Statistical model for the k-means . |
|
This class implements a multivariate diagonal Gaussian distribution |
|
A container for GMM statistics |
|
This class implements the statistical model for multivariate diagonal mixture Gaussian distribution (GMM). |
|
A ISVBase instance can be seen as a container for U and D when performing Joint Factor Analysis (JFA). |
|
A ISVMachine. |
|
Container for \(U\), \(V\) and \(D\) when performing Joint Factor Analysis (JFA). |
|
A JFAMachine. |
|
Statistical model for the Total Variability training for more information and explanation see the user guide in documentation (iVectors) |
|
This class is a container for the \(F\) (between class variantion matrix), \(G\) (within class variantion matrix) and \(\Sigma\) matrices and the mean vector \(\mu\) of a PLDA model. |
|
This class is a container for an enrolled identity/class. |
Functions¶
|
The Linear scoring is an approximation to the log-likelihood ratio that was shown to be as accurate and up to two orders of magnitude more efficient to compute [Glembek2009]. |
|
Trains a machine given a trainer and the proper data |
|
Trains a |
Detailed Information¶
- class bob.learn.em.EMPCATrainer¶
Bases:
objectTrains a
bob.learn.linear.Machineusing an Expectation-Maximization algorithm on the given dataset [Bishop1999] [Roweis1998]Notations used are the ones from [Bishop1999]
The probabilistic model is given by: \(t = Wx + \mu + \epsilon\)
\(t\) is the observed data (dimension \(f\))
\(W\) is a projection matrix (dimension \(f \times d\))
\(x\) is the projected data (dimension \(d < f\))
\(\mu\) is the mean of the data (dimension \(f\))
\(\epsilon\) is the noise of the data (dimension \(f\))
Gaussian with zero-mean and covariance matrix \(\sigma^2 Id\)
Constructor Documentation:
bob.learn.em.EMPCATrainer (other)
bob.learn.em.EMPCATrainer ()
Creates a EMPCATrainer
Parameters:
other:bob.learn.em.EMPCATrainerA EMPCATrainer object to be copied.
Class Members:
- compute_likelihood(linear_machine) None¶
Parameters:
linear_machine:bob.learn.linear.MachineLinearMachine Object
- e_step(linear_machine, data) None¶
Parameters:
linear_machine:bob.learn.linear.MachineLinearMachine Object
data: array_like <float, 2D>Input data
- initialize(linear_machine, data[, rng]) None¶
Parameters:
linear_machine:bob.learn.linear.MachineLinearMachine Object
data: array_like <float, 2D>Input data
rng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- m_step(linear_machine, data) None¶
Parameters:
linear_machine:bob.learn.linear.MachineLinearMachine Object
data: array_like <float, 2D>Input data
- sigma2¶
float <– The noise sigma2 of the probabilistic model
- class bob.learn.em.GMMMachine[source]¶
Bases:
bob.learn.em.GMMMachineThis class implements the statistical model for multivariate diagonal mixture Gaussian distribution (GMM). A GMM is defined as \(\sum_{c=0}^{C} \omega_c \mathcal{N}(x | \mu_c, \sigma_c)\), where \(C\) is the number of Gaussian components \(\mu_c\), \(\sigma_c\) and \(\omega_c\) are respectively the the mean, variance and the weight of each gaussian component \(c\).
See Section 2.3.9 of Bishop, “Pattern recognition and machine learning”, 2006
Constructor Documentation:
bob.learn.em.GMMMachine (n_gaussians,n_inputs)
bob.learn.em.GMMMachine (other)
bob.learn.em.GMMMachine (hdf5)
bob.learn.em.GMMMachine ()
Creates a GMMMachine
Parameters:
n_gaussians: intNumber of gaussians
n_inputs: intDimension of the feature vector
other:bob.learn.em.GMMMachineA GMMMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.GMMStats[source]¶
Bases:
bob.learn.em.GMMStatsA container for GMM statistics
With respect to [Reynolds2000] the class computes:
Eq (8) is
bob.learn.em.GMMStats.n: \(n_i=\sum\limits_{t=1}^T Pr(i | x_t)\)Eq (9) is
bob.learn.em.GMMStats.sum_px: \(E_i(x)=\frac{1}{n(i)}\sum\limits_{t=1}^T Pr(i | x_t)x_t\)Eq (10) is
bob.learn.em.GMMStats.sum_pxx: \(E_i(x^2)=\frac{1}{n(i)}\sum\limits_{t=1}^T Pr(i | x_t)x_t^2\)
Constructor Documentation:
bob.learn.em.GMMStats (n_gaussians,n_inputs)
bob.learn.em.GMMStats (other)
bob.learn.em.GMMStats (hdf5)
bob.learn.em.GMMStats ()
A container for GMM statistics.
Parameters:
n_gaussians: intNumber of gaussians
n_inputs: intDimension of the feature vector
other:bob.learn.em.GMMStatsA GMMStats object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.Gaussian¶
Bases:
objectThis class implements a multivariate diagonal Gaussian distribution
Constructor Documentation:
bob.learn.em.Gaussian (n_inputs)
bob.learn.em.Gaussian (other)
bob.learn.em.Gaussian (hdf5)
bob.learn.em.Gaussian ()
Constructs a new multivariate gaussian object
Parameters:
n_inputs: intDimension of the feature vector
other:bob.learn.em.GMMStatsA GMMStats object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this Gaussian with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.GaussianA gaussian to be compared.
[r_epsilon]: floatRelative precision.
[a_epsilon]: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- load(hdf5) None¶
Load the configuration of the Gassian Machine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
- log_likelihood(input) output¶
Output the log likelihood of the sample, x. The input size is checked.
Note
The
__call__function is an alias for this.Parameters:
input: array_like <float, 1D>Input vector
Returns:
output: floatThe log likelihood
- log_likelihood_(input) output¶
Output the log likelihood given a sample. The input size is NOT checked.
Parameters:
input: array_like <float, 1D>Input vector
Returns:
output: floatThe log likelihood
- mean¶
array_like <float, 1D> <– Mean of the Gaussian
- resize(input) None¶
Set the input dimensionality, reset the mean to zero and the variance to one.
Parameters:
input: intDimensionality of the feature vector
- save(hdf5) None¶
Save the configuration of the Gassian Machine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for writing
- set_variance_thresholds(input) None¶
Set the variance flooring thresholds equal to the given threshold for all the dimensions.
Parameters:
input: floatThreshold
- shape¶
(int) <– A tuple that represents the dimensionality of the Gaussian
(dim,).
- variance¶
array_like <float, 1D> <– Variance of the Gaussian
- variance_thresholds¶
array_like <float, 1D> <– 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.em.ISVBase[source]¶
Bases:
bob.learn.em.ISVBaseA ISVBase instance can be seen as a container for U and D when performing Joint Factor Analysis (JFA).
References: [Vogt2008] [McCool2013]
Constructor Documentation:
bob.learn.em.ISVBase (ubm,ru)
bob.learn.em.ISVBase (other)
bob.learn.em.ISVBase (hdf5)
bob.learn.em.ISVBase ()
Creates a ISVBase
Parameters:
ubm:bob.learn.em.GMMMachineThe Universal Background Model.
ru: intSize of U (Within client variation matrix). In the end the U matrix will have (number_of_gaussians * feature_dimension x ru)
other:bob.learn.em.ISVBaseA ISVBase object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.ISVMachine[source]¶
Bases:
bob.learn.em.ISVMachineA ISVMachine. An attached
bob.learn.em.ISVBaseshould be provided for Joint Factor Analysis. Thebob.learn.em.ISVMachinecarries information about the speaker factors \(y\) and \(z\), whereas abob.learn.em.JFABasecarries information about the matrices \(U\) and \(D\).References: [Vogt2008] [McCool2013]
Constructor Documentation:
bob.learn.em.ISVMachine (isv_base)
bob.learn.em.ISVMachine (other)
bob.learn.em.ISVMachine (hdf5)
Constructor. Builds a new ISVMachine
Parameters:
isv_base:bob.learn.em.ISVBaseThe ISVBase associated with this machine
other:bob.learn.em.ISVMachineA ISVMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.ISVTrainer¶
Bases:
objectISVTrainerTrain Intersession varibility modeling ISV.
Constructor Documentation:
bob.learn.em.ISVTrainer (relevance_factor)
bob.learn.em.ISVTrainer (other)
bob.learn.em.ISVTrainer ()
Constructor. Builds a new ISVTrainer
Parameters:
other:bob.learn.em.ISVTrainerA ISVTrainer object to be copied.
relevance_factor: floatClass Members:
- acc_u_a1¶
array_like <float, 3D> <– Accumulator updated during the E-step
- acc_u_a2¶
array_like <float, 2D> <– Accumulator updated during the E-step
- e_step(isv_base, stats) None¶
Call the e-step procedure (for the U subspace).
Parameters:
isv_base:bob.learn.em.ISVBaseISVBase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- enroll(isv_machine, features, n_iter) None¶
Parameters:
isv_machine:bob.learn.em.ISVMachineISVMachine Object
features: list(bob.learn.em.GMMStats)`n_iter: intNumber of iterations
- initialize(isv_base, stats[, rng]) None¶
Initialization before the EM steps
Parameters:
isv_base:bob.learn.em.ISVBaseISVBase Object
stats:bob.learn.em.GMMStatsGMMStats Object
rng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- m_step(isv_base[, stats]) None¶
Call the m-step procedure (for the U subspace).
Parameters:
isv_base:bob.learn.em.ISVBaseISVBase Object
stats: objectIgnored.
- class bob.learn.em.IVectorMachine[source]¶
Bases:
bob.learn.em.IVectorMachineStatistical model for the Total Variability training for more information and explanation see the user guide in documentation (iVectors)
Constructor Documentation:
bob.learn.em.IVectorMachine (ubm,rt,variance_threshold)
bob.learn.em.IVectorMachine (other)
bob.learn.em.IVectorMachine (hdf5)
Constructor. Builds a new IVectorMachine
Parameters:
ubm:bob.learn.em.GMMMachineThe Universal Background Model.
rt: intSize of the Total Variability matrix (CD x rt).
variance_threshold: floatVariance flooring threshold for the \(\Sigma\) (diagonal) matrix
other:bob.learn.em.IVectorMachineA IVectorMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.IVectorTrainer¶
Bases:
objectIVectorTrainerTrains the Total Variability subspace \($T$\) to generate iVectors.
Constructor Documentation:
bob.learn.em.IVectorTrainer (update_sigma)
bob.learn.em.IVectorTrainer (other)
bob.learn.em.IVectorTrainer ()
Constructor. Builds a new IVectorTrainer
Parameters:
other:bob.learn.em.IVectorTrainerA IVectorTrainer object to be copied.
update_sigma: boolClass Members:
- acc_fnormij_wij¶
array_like <float, 3D> <– Accumulator updated during the E-step
- acc_nij¶
array_like <float, 1D> <– Accumulator updated during the E-step
- acc_nij_wij2¶
array_like <float, 3D> <– Accumulator updated during the E-step
- acc_snormij¶
array_like <float, 2D> <– Accumulator updated during the E-step
- e_step(ivector_machine, stats) None¶
Call the e-step procedure (for the U subspace).
Parameters:
ivector_machine:bob.learn.em.ISVBaseIVectorMachine Object
stats:bob.learn.em.GMMStatsGMMStats Object
- initialize(ivector_machine[, stats][, rng]) None¶
Initialization before the EM steps
Parameters:
ivector_machine:bob.learn.em.IVectorMachineIVectorMachine Object
stats: objectIgnored
rng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- m_step(ivector_machine[, stats]) None¶
Call the m-step procedure (for the U subspace).
Parameters:
ivector_machine:bob.learn.em.ISVBaseIVectorMachine Object
stats: objectIgnored
- reset_accumulators(ivector_machine) None¶
Reset the statistics accumulators to the correct size and a value of zero.
Parameters:
ivector_machine:bob.learn.em.IVectorMachineThe IVector machine containing the right dimensions
- class bob.learn.em.JFABase¶
Bases:
objectContainer for \(U\), \(V\) and \(D\) when performing Joint Factor Analysis (JFA).
Constructor Documentation:
bob.learn.em.JFABase (ubm,ru,rv)
bob.learn.em.JFABase (other)
bob.learn.em.JFABase (hdf5)
bob.learn.em.JFABase ()
Constructor. Builds a new JFABase
Parameters:
ubm:bob.learn.em.GMMMachineThe Universal Background Model.
ru: intSize of \(U\) (Within client variation matrix). In the end the U matrix will have (#gaussians * #feature_dimension x ru)
rv: intSize of \(V\) (Between client variation matrix). In the end the U matrix will have (#gaussians * #feature_dimension x rv)
other:bob.learn.em.JFABaseA JFABase object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- d¶
array_like <float, 1D> <– Returns the diagonal matrix \(diag(d)\) (as a 1D vector)
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this JFABase with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.JFABaseA JFABase object to be compared.
r_epsilon: floatRelative precision.
a_epsilon: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- load(hdf5) None¶
Load the configuration of the JFABase to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
- resize(rU, rV) None¶
Resets the dimensionality of the subspace U and V. U and V are hence uninitialized
Parameters:
rU: intSize of \(U\) (Within client variation matrix)
rV: intSize of \(V\) (Between client variation matrix)
- save(hdf5) None¶
Save the configuration of the JFABase to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for writing
- shape¶
(int,int, int, int) <– A tuple that represents the number of gaussians, dimensionality of each Gaussian, dimensionality of the \(rU\) (within client variability matrix) and dimensionality of the \(rV\) (between client variability matrix)
(#Gaussians, #Inputs, #rU, #rV).
- supervector_length¶
int <– Returns the supervector length.
NGaussians x NInputs: Number of Gaussian components by the feature dimensionalityAn exception is thrown if no Universal Background Model has been set yet.
- u¶
array_like <float, 2D> <– Returns the \(U\) matrix (within client variability matrix)
- ubm¶
bob.learn.em.GMMMachine<– Returns the UBM (Universal Background Model
- v¶
array_like <float, 2D> <– Returns the \(V\) matrix (between client variability matrix)
- class bob.learn.em.JFAMachine¶
Bases:
objectA JFAMachine. An attached
bob.learn.em.JFABaseshould be provided for Joint Factor Analysis. Thebob.learn.em.JFAMachinecarries information about the speaker factors \(y\) and \(z\), whereas abob.learn.em.JFABasecarries information about the matrices \(U\), \(V\) and \(D\).References: [Vogt2008] [McCool2013]
Constructor Documentation:
bob.learn.em.JFAMachine (jfa_base)
bob.learn.em.JFAMachine (other)
bob.learn.em.JFAMachine (hdf5)
Constructor. Builds a new JFAMachine
Parameters:
jfa_base:bob.learn.em.JFABaseThe JFABase associated with this machine
other:bob.learn.em.JFAMachineA JFAMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- estimate_ux(stats, input) None¶
Estimates Ux (LPT assumption) given GMM statistics.
Estimates Ux from the GMM statistics considering the LPT assumption, that is the latent session variable x is approximated using the UBM.
Parameters:
stats:bob.learn.em.GMMStatsStatistics of the GMM
input: array_like <float, 1D>Input vector
- estimate_x(stats, input) None¶
Estimates the session offset x (LPT assumption) given GMM statistics.
Estimates x from the GMM statistics considering the LPT assumption, that is the latent session variable x is approximated using the UBM
Parameters:
stats:bob.learn.em.GMMStatsStatistics of the GMM
input: array_like <float, 1D>Input vector
- forward_ux(stats, ux) None¶
Computes a score for the given UBM statistics and given the Ux vector
Parameters:
stats:bob.learn.em.GMMStatsStatistics as input
ux: array_like <float, 1D>Input vector
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this JFAMachine with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.JFAMachineA JFAMachine object to be compared.
r_epsilon: floatRelative precision.
a_epsilon: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- jfa_base¶
bob.learn.em.JFABase<– The JFABase attached to this machine
- load(hdf5) None¶
Load the configuration of the JFAMachine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
- log_likelihood(stats) None¶
Computes the log-likelihood of the given samples
Note
the
__call__function is an alias for this function.Parameters:
stats:bob.learn.em.GMMStatsStatistics as input
- save(hdf5) None¶
Save the configuration of the JFAMachine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for writing
- shape¶
(int,int, int, int) <– A tuple that represents the number of gaussians, dimensionality of each Gaussian, dimensionality of the rU (within client variability matrix) and dimensionality of the rV (between client variability matrix)
(#Gaussians, #Inputs, #rU, #rV).
- supervector_length¶
int <– Returns the supervector length.
NGaussians x NInputs: Number of Gaussian components by the feature dimensionality. An exception is thrown if no Universal Background Model has been set yet.
- x¶
array_like <float, 1D> <– Returns the \(X\) session factor. Eq (29) from [McCool2013]
The latent variable \(x\) (last one computed). This is a feature provided for convenience, but this attribute is not ‘part’ of the machine. The session latent variable \(x\) is indeed not class-specific, but depends on the sample considered. Furthermore, it is not saved into the machine or used when comparing machines.
- y¶
array_like <float, 1D> <– Returns the \(y\) speaker factor. Eq (30) from [McCool2013]
- z¶
array_like <float, 1D> <– Returns the \(z\) speaker factor. Eq (31) from [McCool2013]
- class bob.learn.em.JFATrainer¶
Bases:
objectTrains a Joint Factor Analysis (JFA) on top of GMMs
Constructor Documentation:
bob.learn.em.JFATrainer (other)
bob.learn.em.JFATrainer ()
Constructor. Builds a new JFATrainer
Parameters:
other:bob.learn.em.JFATrainerA JFATrainer object to be copied.
Class Members:
- acc_d_a1¶
array_like <float, 1D> <– Accumulator updated during the E-step
- acc_d_a2¶
array_like <float, 1D> <– Accumulator updated during the E-step
- acc_u_a1¶
array_like <float, 3D> <– Accumulator updated during the E-step
- acc_u_a2¶
array_like <float, 2D> <– Accumulator updated during the E-step
- acc_v_a1¶
array_like <float, 3D> <– Accumulator updated during the E-step
- acc_v_a2¶
array_like <float, 2D> <– Accumulator updated during the E-step
- e_step_d(jfa_base, stats) None¶
Call the 3rd e-step procedure (for the d subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- e_step_u(jfa_base, stats) None¶
Call the 2nd e-step procedure (for the U subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- e_step_v(jfa_base, stats) None¶
Call the 1st e-step procedure (for the V subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- enroll(jfa_machine, features, n_iter) None¶
Parameters:
jfa_machine:bob.learn.em.JFAMachineJFAMachine Object
features: [bob.learn.em.GMMStats]n_iter: intNumber of iterations
- finalize_d(jfa_base, stats) None¶
Call the 3rd finalize procedure (for the d subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- finalize_u(jfa_base, stats) None¶
Call the 2nd finalize procedure (for the U subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- finalize_v(jfa_base, stats) None¶
Call the 1st finalize procedure (for the V subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- initialize(jfa_base, stats[, rng]) None¶
Initialization before the EM steps
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
rng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- m_step_d(jfa_base, stats) None¶
Call the 3rd m-step procedure (for the d subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- m_step_u(jfa_base, stats) None¶
Call the 2nd m-step procedure (for the U subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- m_step_v(jfa_base, stats) None¶
Call the 1st m-step procedure (for the V subspace).
Parameters:
jfa_base:bob.learn.em.JFABaseJFABase Object
stats:bob.learn.em.GMMStatsGMMStats Object
- class bob.learn.em.KMeansMachine[source]¶
Bases:
bob.learn.em.KMeansMachineStatistical model for the k-means . See Section 9.1 of Bishop, “Pattern recognition and machine learning”, 2006
Constructor Documentation:
bob.learn.em.KMeansMachine (n_means,n_inputs)
bob.learn.em.KMeansMachine (other)
bob.learn.em.KMeansMachine (hdf5)
bob.learn.em.KMeansMachine ()
Creates a KMeansMachine
Parameters:
n_means: intNumber of means
n_inputs: intDimension of the feature vector
other:bob.learn.em.KMeansMachineA KMeansMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- class bob.learn.em.KMeansTrainer¶
Bases:
objectTrains a KMeans clustering k-means.This class implements the expectation-maximization algorithm for a k-means.See Section 9.1 of Bishop, “Pattern recognition and machine learning”, 2006It uses a random initialization of the means followed by the expectation-maximization algorithm
Constructor Documentation:
bob.learn.em.KMeansTrainer (initialization_method)
bob.learn.em.KMeansTrainer (other)
bob.learn.em.KMeansTrainer ()
Creates a KMeansTrainer
Parameters:
initialization_method: strThe initialization method of the means. Possible values are: ‘RANDOM’, ‘RANDOM_NO_DUPLICATE’, ‘KMEANS_PLUS_PLUS’
other:bob.learn.em.KMeansTrainerA KMeansTrainer object to be copied.
Class Members:
- average_min_distance¶
str <– Average min (square Euclidean) distance. Useful to parallelize the E-step.
- compute_likelihood(kmeans_machine) None¶
This functions returns the average min (Square Euclidean) distance (average distance to the closest mean)
Parameters:
kmeans_machine:bob.learn.em.KMeansMachineKMeansMachine Object
- e_step(kmeans_machine, data) None¶
Compute the E-step, which is basically the distances
Accumulate across the dataset: -zeroeth and first order statistics -average (Square Euclidean) distance from the closest mean
Parameters:
kmeans_machine:bob.learn.em.KMeansMachineKMeansMachine Object
data: array_like <float, 2D>Input data
- first_order_statistics¶
array_like <float, 2D> <– Returns the internal statistics. Useful to parallelize the E-step
- initialization_method¶
str <– Initialization method.
- Possible values:
RANDOM: Random initialization
RANDOM_NO_DUPLICATE: Random initialization without repetition
KMEANS_PLUS_PLUS: Apply the kmeans++ initialization http://en.wikipedia.org/wiki/K-means%2B%2B
- initialize(kmeans_machine, data[, rng]) None¶
Initialise the means randomly
Data is split into as many chunks as there are means, then each mean is set to a random example within each chunk.
Parameters:
kmeans_machine:bob.learn.em.KMeansMachineKMeansMachine Object
data: array_like <float, 2D>Input data
rng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- m_step(kmeans_machine[, data]) None¶
Updates the mean based on the statistics from the E-step
Parameters:
kmeans_machine:bob.learn.em.KMeansMachineKMeansMachine Object
data: objectIgnored.
- reset_accumulators(kmeans_machine) None¶
Reset the statistics accumulators to the correct size and a value of zero.
Parameters:
kmeans_machine:bob.learn.em.KMeansMachineKMeansMachine Object
- zeroeth_order_statistics¶
array_like <float, 1D> <– Returns the internal statistics. Useful to parallelize the E-step
- class bob.learn.em.MAP_GMMTrainer¶
Bases:
objectThis class implements the maximum a posteriori (MAP) M-step of the expectation-maximization 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.
Constructor Documentation:
bob.learn.em.MAP_GMMTrainer (prior_gmm, relevance_factor, [update_means], [update_variances], [update_weights], [mean_var_update_responsibilities_threshold])
bob.learn.em.MAP_GMMTrainer (prior_gmm, alpha, [update_means], [update_variances], [update_weights], [mean_var_update_responsibilities_threshold])
bob.learn.em.MAP_GMMTrainer (other)
Creates a MAP_GMMTrainer
Additionally to the copy constructor, there are two different ways to call this constructor, one using the
relevance_factorand one using thealpha, both which have the same signature. Hence, the only way to differentiate the two functions is by using keyword arguments.Parameters:
prior_gmm:bob.learn.em.GMMMachineThe prior GMM to be adapted (Universal Background Model UBM).
relevance_factor: floatIf set the Reynolds Adaptation procedure will be applied. See Eq (14) from [Reynolds2000]
alpha: floatSet directly the alpha parameter (Eq (14) from [Reynolds2000]), ignoring zeroth order statistics as a weighting factor.
update_means: bool[Default:
True] Update means on each iterationupdate_variances: bool[Default:
True] Update variances on each iterationupdate_weights: bool[Default:
True] Update weights on each iterationmean_var_update_responsibilities_threshold: float[Default: min_float] Threshold over the responsibilities of the Gaussians Equations 9.24, 9.25 of Bishop, Pattern recognition and machine learning, 2006 require a division by the responsibilities, which might be equal to zero because of numerical issue. This threshold is used to avoid such divisions.
other:bob.learn.em.MAP_GMMTrainerA MAP_GMMTrainer object to be copied.
Class Members:
- alpha¶
float <– Set directly the alpha parameter (Eq (14) from [Reynolds2000]), ignoring zeroth order statistics as a weighting factor.
- compute_likelihood(gmm_machine) None¶
This functions returns the average min (Square Euclidean) distance (average distance to the closest mean)
Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
- e_step(gmm_machine, data) None¶
Calculates and saves statistics across the dataset and saves these as
gmm_statistics.Calculates the average log likelihood of the observations given the GMM,and returns this in average_log_likelihood.The statistics,
gmm_statistics, will be used in them_step()that follows.Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: array_like <float, 2D>Input data
- gmm_statistics¶
GMMStats<– The GMM statistics that were used internally in the E- and M-stepsSetting and getting the internal GMM statistics might be useful to parallelize the GMM training.
- initialize(gmm_machine[, data][, rng]) None¶
Initialization before the EM steps
Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: objectIgnored.
rng: objectIgnored.
- m_step(gmm_machine[, data]) None¶
Performs a maximum a posteriori (MAP) update of the GMM parameters using the accumulated statistics in
gmm_statisticsand the parameters of the prior modelParameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: objectIgnored.
- relevance_factor¶
float <– If set the reynolds_adaptation parameters, will apply the Reynolds Adaptation Factor. See Eq (14) from [Reynolds2000]
- class bob.learn.em.ML_GMMTrainer¶
Bases:
objectThis class implements the maximum likelihood M-step (MLE) of the expectation-maximisation algorithm for a GMM Machine.
Constructor Documentation:
bob.learn.em.ML_GMMTrainer (update_means, [update_variances], [update_weights], [mean_var_update_responsibilities_threshold])
bob.learn.em.ML_GMMTrainer (other)
Creates a ML_GMMTrainer
Parameters:
update_means: boolUpdate means on each iteration
update_variances: boolUpdate variances on each iteration
update_weights: boolUpdate weights on each iteration
mean_var_update_responsibilities_threshold: floatThreshold over the responsibilities of the Gaussians Equations 9.24, 9.25 of Bishop, Pattern recognition and machine learning, 2006 require a division by the responsibilities, which might be equal to zero because of numerical issue. This threshold is used to avoid such divisions.
other:bob.learn.em.ML_GMMTrainerA ML_GMMTrainer object to be copied.
Class Members:
- compute_likelihood(gmm_machine) None¶
This functions returns the average min (Square Euclidean) distance (average distance to the closest mean)
Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
- e_step(gmm_machine, data) None¶
Calculates and saves statistics across the dataset,and saves these as m_ss.
Calculates the average log likelihood of the observations given the GMM,and returns this in average_log_likelihood.The statistics,
gmm_statistics, will be used in them_step()that follows.Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: array_like <float, 2D>Input data
- gmm_statistics¶
GMMStats<– The GMM statistics that were used internally in the E- and M-stepsSetting and getting the internal GMM statistics might be useful to parallelize the GMM training.
- initialize(gmm_machine[, data][, rng]) None¶
Initialization before the EM steps
Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: objectIgnored.
rng: objectIgnored.
- m_step(gmm_machine[, data]) None¶
Performs a maximum likelihood (ML) update of the GMM parameters using the accumulated statistics in
gmm_statisticsSee Section 9.2.2 of Bishop, “Pattern recognition and machine learning”, 2006
Parameters:
gmm_machine:bob.learn.em.GMMMachineGMMMachine Object
data: objectIgnored.
- class bob.learn.em.PLDABase¶
Bases:
objectThis class is a container for the \(F\) (between class variantion matrix), \(G\) (within class variantion matrix) and \(\Sigma\) matrices and the mean vector \(\mu\) of a PLDA model. This alsoprecomputes useful matrices to make the model scalable.References: [ElShafey2014] [PrinceElder2007] [LiFu2012]
Constructor Documentation:
bob.learn.em.PLDABase (dim_d,dim_f,dim_g,variance_threshold)
bob.learn.em.PLDABase (other)
bob.learn.em.PLDABase (hdf5)
Constructor, builds a new PLDABase. \(F\), \(G\) and \(\Sigma\) are initialized to the ‘eye’ matrix (matrix with 1’s on the diagonal and 0 outside), and \(\mu\) is initialized to 0.
Parameters:
dim_d: intDimensionality of the feature vector.
dim_f: intSize of \(F\) (between class variantion matrix).
dim_g: intSize of \(G\) (within class variantion matrix).
variance_threshold: floatThe smallest possible value of the variance (Ignored if set to 0.)
other:bob.learn.em.PLDABaseA PLDABase object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- compute_gamma(a, res) None¶
Tells if the \(\gamma_a\) matrix for a given a (number of samples) exists. \(\gamma_a=(Id + a F^T \beta F)^{-1}\)
Parameters:
a: intIndex
res: array_like <float, 2D>Input data
- compute_log_like_const_term(a, res) None¶
Computes the log likelihood constant term for a given \(a\) (number of samples), given the provided \(\gamma_a\) matrix. \(l_{a} = \frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|\gamma_a|)\)
Parameters:
a: intIndex
res: array_like <float, 2D>Input data
- compute_log_likelihood_point_estimate(xij, hi, wij) output¶
Gets the log-likelihood of an observation, given the current model and the latent variables (point estimate).This will basically compute \(p(x_{ij} | h_{i}, w_{ij}, \Theta)\), given by \(\mathcal{N}(x_{ij}|[\mu + F h_{i} + G w_{ij} + \epsilon_{ij}, \Sigma])\), which is in logarithm, \(\frac{D}{2} log(2\pi) -\frac{1}{2} log(det(\Sigma)) -\frac{1}{2} {(x_{ij}-(\mu+F h_{i}+G w_{ij}))^{T}\Sigma^{-1}(x_{ij}-(\mu+F h_{i}+G w_{ij}))}\)
Parameters:
xij: array_like <float, 1D>hi: array_like <float, 1D>wij: array_like <float, 1D>Returns:
output: float
- f¶
array_like <float, 2D> <– Returns the \(F\) matrix (between class variantion matrix)
- g¶
array_like <float, 2D> <– Returns the \(G\) matrix (between class variantion matrix)
- get_add_gamma(a) output¶
Gets the \(gamma_a\) matrix for a given \(f_a\) (number of samples). \(\gamma_a=(Id + a F^T \beta F)^{-1} =\mathcal{F}_{a}\).Tries to find it from the base machine and then from this machine.
Parameters:
a: intIndex
Returns:
output: array_like <float, 2D>
- get_add_log_like_const_term(a) output¶
Gets the log likelihood constant term for a given \(a\) (number of samples). \(l_{a} = \frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|\gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: float
- get_gamma(a) output¶
Gets the \(\gamma_a\) matrix for a given \(a\) (number of samples). \(\gamma_{a}=(Id + a F^T \beta F)^{-1} = \mathcal{F}_{a}\)
Parameters:
a: intIndex
Returns:
output: array_like <float, 2D>Get the \(\gamma\) matrix
- get_log_like_const_term(a) output¶
Gets the log likelihood constant term for a given \(a\) (number of samples). \(l_{a}=\frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|\gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: float
- has_gamma(a) output¶
Tells if the \(\gamma_a\) matrix for a given a (number of samples) exists. \(\gamma_a=(Id + aF^T \beta F)^{-1}\)
Parameters:
a: intIndex
Returns:
output: bool
- has_log_like_const_term(a) output¶
Tells if the log likelihood constant term for a given \(a\) (number of samples) exists in this machine (does not check the base machine). \(l_{a}=\frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|\gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: bool
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this PLDABase with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.PLDABaseA PLDABase object to be compared.
r_epsilon: floatRelative precision.
a_epsilon: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- load(hdf5) None¶
Load the configuration of the PLDABase to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
- mu¶
array_like <float, 1D> <– Gets the \(\mu\) mean vector of the PLDA model
- resize(dim_d, dim_f, dim_g) None¶
Resizes the dimensionality of the PLDA model. Paramaters \(\mu\), \(F\), \(G\) and \(\Sigma\) are reinitialized.
Parameters:
dim_d: intDimensionality of the feature vector.
dim_f: intSize of \(F\) (between class variantion matrix).
dim_g: intSize of \(G\) (within class variantion matrix).
- save(hdf5) None¶
Save the configuration of the PLDABase to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for writing
- shape¶
(int,int, int) <– A tuple that represents the dimensionality of the feature vector dim_d, the \(F\) matrix and the \(G\) matrix.
- sigma¶
array_like <float, 1D> <– Gets the \(\sigma\) (diagonal) covariance matrix of the PLDA model
- variance_threshold¶
float <–
- class bob.learn.em.PLDAMachine¶
Bases:
objectThis class is a container for an enrolled identity/class. It contains information extracted from the enrollment samples. It should be used in combination with a PLDABase instance.
References: [ElShafey2014] [PrinceElder2007] [LiFu2012]
Constructor Documentation:
bob.learn.em.PLDAMachine (plda_base)
bob.learn.em.PLDAMachine (other)
bob.learn.em.PLDAMachine (hdf5,plda_base)
Constructor, builds a new PLDAMachine.
Parameters:
plda_base:bob.learn.em.PLDABaseother:bob.learn.em.PLDAMachineA PLDAMachine object to be copied.
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
Class Members:
- compute_log_likelihood(sample, with_enrolled_samples) output¶
Compute the log-likelihood of the given sample and (optionally) the enrolled samples
Parameters:
sample: array_like <float, 1D>,array_like <float, 2D>Sample
with_enrolled_samples: boolReturns:
output: floatThe log-likelihood
- get_add_gamma(a) output¶
Gets the \(gamma_a\) matrix for a given \(f_a\) (number of samples). \(\gamma_a=(Id + a F^T \beta F)^{-1} =\mathcal{F}_{a}\).Tries to find it from the base machine and then from this machine.
Parameters:
a: intIndex
Returns:
output: array_like <float, 2D>
- get_add_log_like_const_term(a) output¶
Gets the log likelihood constant term for a given \(a\) (number of samples). \(l_{a} = \frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: float
- get_gamma(a) output¶
Gets the \(\gamma_a\) matrix for a given \(a\) (number of samples). \(\gamma_{a}=(Id + a F^T \beta F)^{-1}= \mathcal{F}_{a}\)
Parameters:
a: intIndex
Returns:
output: array_like <float, 2D>Get the \(\gamma\) matrix
- get_log_like_const_term(a) output¶
Gets the log likelihood constant term for a given \(a\) (number of samples). \(l_{a}=\frac{a}{2}( -D log(2\pi) -log|\Sigma| +log|\alpha| + log|\gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: float
- has_gamma(a) output¶
Tells if the \(\gamma_a\) matrix for a given a (number of samples) exists. \(\gamma_a=(Id + a F^T \beta F)^{-1}\)
Parameters:
a: intIndex
Returns:
output: bool
- has_log_like_const_term(a) output¶
Tells if the log likelihood constant term for a given \(a\) (number of samples) exists in this machine (does not check the base machine). \(l_{a}=\frac{a}{2} ( -D log(2\pi) -log|\Sigma| +log|\alpha| +log|\gamma_a|)\)
Parameters:
a: intIndex
Returns:
output: bool
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this PLDAMachine with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.PLDAMachineA PLDAMachine object to be compared.
r_epsilon: floatRelative precision.
a_epsilon: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- load(hdf5) None¶
Load the configuration of the PLDAMachine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for reading
- log_likelihood¶
float <– Get the current log likelihood
- log_likelihood_ratio(samples) output¶
Computes a log likelihood ratio from a 1D or 2D blitz::Array
Parameters:
samples: array_like <float, 1D>,array_like <float, 2D>Sample
Returns:
output: floatThe log-likelihood ratio
- n_samples¶
int <– Number of enrolled samples
- plda_base¶
bob.learn.em.PLDABase<– The PLDABase attached to this machine
- save(hdf5) None¶
Save the configuration of the PLDAMachine to a given HDF5 file
Parameters:
hdf5:bob.io.base.HDF5FileAn HDF5 file open for writing
- shape¶
(int,int, int) <– A tuple that represents the dimensionality of the feature vector dim_d, the \(F\) matrix and the \(G\) matrix.
- w_sum_xit_beta_xi¶
float <– Gets the \(A = -0.5 \sum_{i} x_{i}^T \beta x_{i}\) value
- weighted_sum¶
array_like <float, 1D> <– Get/Set \(\sum_{i} F^T \beta x_{i}\) value
- class bob.learn.em.PLDATrainer¶
Bases:
objectThis class can be used to train the \(F\), \(G\) and \(\Sigma\) matrices and the mean vector \(\mu\) of a PLDA model.References: [ElShafey2014] [PrinceElder2007] [LiFu2012]
Constructor Documentation:
bob.learn.em.PLDATrainer (use_sum_second_order)
bob.learn.em.PLDATrainer (other)
bob.learn.em.PLDATrainer ()
- Default constructor.
Initializes a new PLDA trainer. The training stage will place the resulting components in the PLDABase.
Parameters:
other:bob.learn.em.PLDATrainerA PLDATrainer object to be copied.
use_sum_second_order: boolClass Members:
- e_step(plda_base, data) None¶
Expectation step before the EM steps
Parameters:
plda_base:bob.learn.em.PLDABasePLDAMachine Object
data: list
- enroll(plda_machine, data) None¶
Main procedure for enrolling a PLDAMachine
Parameters:
plda_machine:bob.learn.em.PLDAMachinePLDAMachine Object
data: list
- finalize(plda_base, data) None¶
finalize before the EM steps
Parameters:
plda_base:bob.learn.em.PLDABasePLDAMachine Object
data: list
- init_f_method¶
str <– The method used for the initialization of \($F$\).
Possible values are: (‘RANDOM_F’, ‘BETWEEN_SCATTER’)
- init_g_method¶
str <– The method used for the initialization of \($G$\).
Possible values are: (‘RANDOM_G’, ‘WITHIN_SCATTER’)
- init_sigma_method¶
str <– The method used for the initialization of \($\Sigma$\).
Possible values are: (‘RANDOM_SIGMA’, ‘VARIANCE_G’, ‘CONSTANT’, ‘VARIANCE_DATA’)
- initialize(plda_base, data[, rng]) None¶
Initialization before the EM steps
Parameters:
plda_base:bob.learn.em.PLDABasePLDAMachine Object
data: listrng:bob.core.random.mt19937The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop.
- is_similar_to(other[, r_epsilon][, a_epsilon]) output¶
Compares this PLDATrainer with the
otherone to be approximately the same.The optional values
r_epsilonanda_epsilonrefer to the relative and absolute precision for theweights,biasesand any other values internal to this machine.Parameters:
other:bob.learn.em.PLDAMachineA PLDAMachine object to be compared.
r_epsilon: floatRelative precision.
a_epsilon: floatAbsolute precision.
Returns:
output: boolTrue if it is similar, otherwise false.
- m_step(plda_base, data) None¶
Maximization step
Parameters:
plda_base:bob.learn.em.PLDABasePLDAMachine Object
data: list
- use_sum_second_order¶
bool <– Tells whether the second order statistics are stored during the training procedure, or only their sum.
- z_first_order¶
array_like <float, 2D> <–
- z_second_order¶
array_like <float, 3D> <–
- z_second_order_sum¶
array_like <float, 2D> <–
- class bob.learn.em.ThreadPool(processes=None, initializer=None, initargs=())[source]¶
Bases:
multiprocessing.pool.Pool
- bob.learn.em.linear_scoring(models, ubm, test_stats, test_channelOffset, frame_length_normalisation) output¶
The Linear scoring is an approximation to the log-likelihood ratio that was shown to be as accurate and up to two orders of magnitude more efficient to compute [Glembek2009].
Parameters:
models: [bob.learn.em.GMMMachine]ubm:bob.learn.em.GMMMachinetest_stats: [bob.learn.em.GMMStats]test_channelOffset: [array_like<float,1>]frame_length_normalisation: boolReturns:
output: array_like<float,1>Score
- bob.learn.em.train(trainer, machine, data, max_iterations=50, convergence_threshold=None, initialize=True, rng=None, check_inputs=True, pool=None, trainer_type=None)[source]¶
Trains a machine given a trainer and the proper data
- Parameters:
- trainerone of
KMeansTrainer,MAP_GMMTrainer,ML_GMMTrainer,ISVTrainer,IVectorTrainer,PLDATrainer,EMPCATrainer A trainer mechanism
- machineone of
KMeansMachine,GMMMachine,ISVBase,IVectorMachine,PLDAMachine,bob.learn.linear.Machine A container machine
- dataarray_like <float, 2D>
The data to be trained
- max_iterationsint
The maximum number of iterations to train a machine
- convergence_thresholdfloat
The convergence threshold to train a machine. If None, the training procedure will stop with the iterations criteria
- initializebool
If True, runs the initialization procedure
- rng
bob.core.random.mt19937 The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop
- check_inputs:
Shallow checks in the inputs. Check for inf and NaN
- pool
intormultiprocessing.ThreadPoolorNone If given, the provided process pool will be used to parallelize the M-step of the EM algorithm. You should provide a ThreadPool not a multi process Pool. If pool is an integer, it will be used to create a ThreadPool with that many processes.
- trainer_type
strorNone This is used for the parallel e_step method to see how several processes’ data can be merged into one trainer before the m_step. By default
trainer.__class__.__name__is used. This is useful if you have custom trainers and want to use this function.
- trainerone of
- bob.learn.em.train_jfa(trainer, jfa_base, data, max_iterations=10, initialize=True, rng=None)[source]¶
Trains a
bob.learn.em.JFABasegiven abob.learn.em.JFATrainerand the proper data- Parameters:
- trainer
bob.learn.em.JFATrainer A JFA trainer mechanism
- jfa_base
bob.learn.em.JFABase A container machine
- data[[
bob.learn.em.GMMStats]] The data to be trained
- max_iterationsint
The maximum number of iterations to train a machine
- initializebool
If True, runs the initialization procedure
- rng
bob.core.random.mt19937 The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loops
- trainer