Trains a machine given a trainer and the proper data
"""
Trains a machine given a trainer and the proper data
**Parameters**:
trainer : one of :py:class:`KMeansTrainer`, :py:class:`MAP_GMMTrainer`, :py:class:`ML_GMMTrainer`, :py:class:`ISVTrainer`, :py:class:`IVectorTrainer`, :py:class:`PLDATrainer`, :py:class:`EMPCATrainer`
**Parameters**:
A trainer mechanism
trainer : one of :py:class:`KMeansTrainer`, :py:class:`MAP_GMMTrainer`, :py:class:`ML_GMMTrainer`, :py:class:`ISVTrainer`, :py:class:`IVectorTrainer`, :py:class:`PLDATrainer`, :py:class:`EMPCATrainer`
machine : one of :py:class:`KMeansMachine`, :py:class:`GMMMachine`, :py:class:`ISVBase`, :py:class:`IVectorMachine`, :py:class:`PLDAMachine`, :py:class:`bob.learn.linear.Machine`
A trainer mechanism
A container machine
machine : one of :py:class:`KMeansMachine`, :py:class:`GMMMachine`, :py:class:`ISVBase`, :py:class:`IVectorMachine`, :py:class:`PLDAMachine`, :py:class:`bob.learn.linear.Machine`
data : array_like <float, 2D>
A container machine
The data to be trained
data : array_like <float, 2D>
max_iterations : int
The data to be trained
The maximum number of iterations to train a machine
max_iterations : int
convergence_threshold : float
The maximum number of iterations to train a machine
The convergence threshold to train a machine. If None, the training procedure will stop with the iterations criteria
convergence_threshold : float
initialize : bool
The convergence threshold to train a machine. If None, the training procedure will stop with the iterations criteria
If True, runs the initialization procedure
initialize : bool
rng : :py:class:`bob.core.random.mt19937`
If True, runs the initialization procedure
The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop
rng : :py:class:`bob.core.random.mt19937`
"""
The Mersenne Twister mt19937 random generator used for the initialization of subspaces/arrays before the EM loop
#Initialization
check_inputs: Shallow checks in the inputs. Check for inf and NaN
ifinitialize:
"""
ifrngisnotNone:
trainer.initialize(machine,data,rng)
ifcheck_inputs:
else:
ifnumpy.isinf(numpy.sum(data)):
trainer.initialize(machine,data)
raiseValueError("Please, check your inputs; numpy.inf detected in `data` ")
trainer.e_step(machine,data)
ifnumpy.isnan(numpy.sum(data)):
average_output=0
raiseValueError("Please, check your inputs; numpy.nan detected in `data` ")