Commit 2601b117 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Added more tests with blitz arrays

parent d95e400f
......@@ -185,7 +185,7 @@ PyObject* PyBobLearnEMMAPGMMTrainer_getRelevanceFactor(PyBobLearnEMMAPGMMTrainer
int PyBobLearnEMMAPGMMTrainer_setRelevanceFactor(PyBobLearnEMMAPGMMTrainerObject* self, PyObject* value, void*){
BOB_TRY
if(!PyNumber_Check(value)){
if(!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a double", Py_TYPE(self)->tp_name, relevance_factor.name());
return -1;
}
......@@ -211,7 +211,7 @@ PyObject* PyBobLearnEMMAPGMMTrainer_getAlpha(PyBobLearnEMMAPGMMTrainerObject* se
int PyBobLearnEMMAPGMMTrainer_setAlpha(PyBobLearnEMMAPGMMTrainerObject* self, PyObject* value, void*){
BOB_TRY
if(!PyNumber_Check(value)){
if(!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a double", Py_TYPE(self)->tp_name, alpha.name());
return -1;
}
......
......@@ -75,6 +75,10 @@ void bob::learn::em::MAP_GMMTrainer::mStep(bob::learn::em::GMMMachine& gmm)
{
// Read options and variables
double n_gaussians = gmm.getNGaussians();
//Checking if it is necessary to resize the cache
if((size_t)m_cache_alpha.extent(0) != n_gaussians)
initialize(gmm); //If it is different for some reason, there is no way, you have to initialize
// Check that the prior GMM has been specified
if (!m_prior_gmm)
......
......@@ -41,6 +41,10 @@ void bob::learn::em::ML_GMMTrainer::mStep(bob::learn::em::GMMMachine& gmm)
// Read options and variables
const size_t n_gaussians = gmm.getNGaussians();
//Checking if it is necessary to resize the cache
if((size_t)m_cache_ss_n_thresholded.extent(0) != n_gaussians)
initialize(gmm); //If it is different for some reason, there is no way, you have to initialize
// - Update weights if requested
// Equation 9.26 of Bishop, "Pattern recognition and machine learning", 2006
if (m_gmm_base_trainer.getUpdateWeights()) {
......@@ -101,12 +105,3 @@ bool bob::learn::em::ML_GMMTrainer::operator!=
{
return !(this->operator==(other));
}
/*
bool bob::learn::em::ML_GMMTrainer::is_similar_to
(const bob::learn::em::ML_GMMTrainer &other, const double r_epsilon,
const double a_epsilon) const
{
return m_gmm_base_trainer.is_similar_to(other, r_epsilon, a_epsilon);
}
*/
......@@ -105,7 +105,7 @@ static int PyBobLearnEMGaussian_init(PyBobLearnEMGaussianObject* self, PyObject*
}
/**If the constructor input is a number**/
if (PyNumber_Check(arg))
if (PyBob_NumberCheck(arg))
return PyBobLearnEMGaussian_init_number(self, args, kwargs);
/**If the constructor input is Gaussian object**/
else if (PyBobLearnEMGaussian_Check(arg))
......
......@@ -350,7 +350,7 @@ PyObject* PyBobLearnEMGMMStats_getLog_likelihood(PyBobLearnEMGMMStatsObject* sel
int PyBobLearnEMGMMStats_setLog_likelihood(PyBobLearnEMGMMStatsObject* self, PyObject* value, void*){
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an double", Py_TYPE(self)->tp_name, t.name());
return -1;
}
......
......@@ -270,7 +270,7 @@ PyObject* PyBobLearnEMIVectorMachine_getVarianceThreshold(PyBobLearnEMIVectorMac
int PyBobLearnEMIVectorMachine_setVarianceThreshold(PyBobLearnEMIVectorMachineObject* self, PyObject* value, void*){
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an double", Py_TYPE(self)->tp_name, variance_threshold.name());
return -1;
}
......
......@@ -49,7 +49,7 @@ static auto KMeansTrainer_doc = bob::extension::ClassDoc(
.add_prototype("other","")
.add_prototype("","")
.add_parameter("initialization_method", "str", "The initialization method of the means")
.add_parameter("initialization_method", "str", "The initialization method of the means.\nPossible values are: 'RANDOM', 'RANDOM_NO_DUPLICATE', 'KMEANS_PLUS_PLUS' ")
.add_parameter("other", ":py:class:`bob.learn.em.KMeansTrainer`", "A KMeansTrainer object to be copied.")
);
......@@ -162,7 +162,10 @@ static auto initialization_method = bob::extension::VariableDoc(
"initialization_method",
"str",
"Initialization method.",
""
"Possible values:\n"
" `RANDOM`: Random initialization \n\n"
" `RANDOM_NO_DUPLICATE`: Random initialization without repetition \n\n"
" `KMEANS_PLUS_PLUS`: Apply the kmeans++ initialization http://en.wikipedia.org/wiki/K-means%2B%2B \n\n"
);
PyObject* PyBobLearnEMKMeansTrainer_getInitializationMethod(PyBobLearnEMKMeansTrainerObject* self, void*) {
BOB_TRY
......@@ -254,7 +257,7 @@ PyObject* PyBobLearnEMKMeansTrainer_getAverageMinDistance(PyBobLearnEMKMeansTrai
int PyBobLearnEMKMeansTrainer_setAverageMinDistance(PyBobLearnEMKMeansTrainerObject* self, PyObject* value, void*) {
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an double", Py_TYPE(self)->tp_name, average_min_distance.name());
return -1;
}
......
......@@ -397,7 +397,7 @@ static PyObject* PyBobLearnEMPLDABase_getVarianceThreshold(PyBobLearnEMPLDABaseO
int PyBobLearnEMPLDABase_setVarianceThreshold(PyBobLearnEMPLDABaseObject* self, PyObject* value, void*){
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an float", Py_TYPE(self)->tp_name, variance_threshold.name());
return -1;
}
......
......@@ -220,7 +220,7 @@ static PyObject* PyBobLearnEMPLDAMachine_getWSumXitBetaXi(PyBobLearnEMPLDAMachin
int PyBobLearnEMPLDAMachine_setWSumXitBetaXi(PyBobLearnEMPLDAMachineObject* self, PyObject* value, void*){
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an float", Py_TYPE(self)->tp_name, w_sum_xit_beta_xi.name());
return -1;
}
......@@ -312,7 +312,7 @@ static PyObject* PyBobLearnEMPLDAMachine_getLogLikelihood(PyBobLearnEMPLDAMachin
int PyBobLearnEMPLDAMachine_setLogLikelihood(PyBobLearnEMPLDAMachineObject* self, PyObject* value, void*){
BOB_TRY
if (!PyNumber_Check(value)){
if (!PyBob_NumberCheck(value)){
PyErr_Format(PyExc_RuntimeError, "%s %s expects an double", Py_TYPE(self)->tp_name, log_likelihood.name());
return -1;
}
......
2.0.0b3
\ No newline at end of file
2.0.0b6
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment