Skip to content

Commit

Permalink
fix unit-tests after change in the training initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules Françoise committed Sep 6, 2016
1 parent 21cf963 commit 699f8ac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 70 deletions.
10 changes: 5 additions & 5 deletions ide/xcode/xmm-lib.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
path = src;
sourceTree = "<group>";
};
0B9FE3091AD16269007431E3 /* test */ = {
0B9FE3091AD16269007431E3 /* tests */ = {
isa = PBXGroup;
children = (
0B9FE30A1AD1627E007431E3 /* catch.hpp */,
Expand All @@ -267,19 +267,19 @@
0BF36B561AE82DEA00D81858 /* xmmTestsModelExtraction.cpp */,
FA61EB661CC9797100F37E4E /* xmmTestsComplexity.cpp */,
);
name = test;
name = tests;
path = ../../test;
sourceTree = "<group>";
};
0BD1C5BF17D9E3BA0061535A = {
isa = PBXGroup;
children = (
FA41CABC1C28A9D800905379 /* jsoncpp */,
0B931DBD1AB1B17B00B15F3E /* readme.md */,
0B4909A61947718400E0D3C4 /* src */,
0B9FE3091AD16269007431E3 /* tests */,
FA41CABC1C28A9D800905379 /* jsoncpp */,
0BD1C5E417D9E3D20061535A /* doc */,
0B9FE2C21ACF6893007431E3 /* python */,
0B4909A61947718400E0D3C4 /* src */,
0B9FE3091AD16269007431E3 /* test */,
0B20E08F1A9A633600E89497 /* Products */,
);
sourceTree = "<group>";
Expand Down
101 changes: 36 additions & 65 deletions test/xmmTestsMultithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ TEST_CASE("Training with MultithreadingMode::Sequential", "[GMM]") {
a.configuration.gaussians.set(3);
CHECK_NOTHROW(a.train(&ts));
std::vector<float> mixtureCoeffs(3);
mixtureCoeffs[0] = 3.819443583488e-01;
mixtureCoeffs[1] = 3.171715140343e-01;
mixtureCoeffs[2] = 3.008841276169e-01;
mixtureCoeffs[0] = 0.410568;
mixtureCoeffs[1] = 0.309933;
mixtureCoeffs[2] = 0.2795;
CHECK_VECTOR_APPROX(a.models[label_a].mixture_coeffs, mixtureCoeffs);
std::vector<double> cov_c0(9);
cov_c0[0] = 1.398498568044e-02;
cov_c0[1] = 5.041130937517e-03;
cov_c0[2] = 1.792829737244e-03;
cov_c0[3] = 5.041130937517e-03;
cov_c0[4] = 3.113048333532e-03;
cov_c0[5] = 7.901977752380e-04;
cov_c0[6] = 1.792829737244e-03;
cov_c0[7] = 7.901977752380e-04;
cov_c0[8] = 1.306463534393e-03;
cov_c0[0] = 0.018729;
cov_c0[1] = 0.00683308;
cov_c0[2] = 0.00271096;
cov_c0[3] = 0.00683308;
cov_c0[4] = 0.00614827;
cov_c0[5] = 0.00133768;
cov_c0[6] = 0.00271096;
cov_c0[7] = 0.00133768;
cov_c0[8] = 0.00337321;
CHECK_VECTOR_APPROX(a.models[label_a].components[0].covariance, cov_c0);
}

Expand Down Expand Up @@ -132,20 +132,20 @@ TEST_CASE("Training with MultithreadingMode::MultithreadingMode", "[GMM]") {
a.configuration.gaussians.set(3);
a.train(&ts);
std::vector<float> mixtureCoeffs(3);
mixtureCoeffs[0] = 3.819443583488e-01;
mixtureCoeffs[1] = 3.171715140343e-01;
mixtureCoeffs[2] = 3.008841276169e-01;
mixtureCoeffs[0] = 0.410568;
mixtureCoeffs[1] = 0.309933;
mixtureCoeffs[2] = 0.2795;
CHECK_VECTOR_APPROX(a.models[label_a].mixture_coeffs, mixtureCoeffs);
std::vector<double> cov_c0(9);
cov_c0[0] = 1.398498568044e-02;
cov_c0[1] = 5.041130937517e-03;
cov_c0[2] = 1.792829737244e-03;
cov_c0[3] = 5.041130937517e-03;
cov_c0[4] = 3.113048333532e-03;
cov_c0[5] = 7.901977752380e-04;
cov_c0[6] = 1.792829737244e-03;
cov_c0[7] = 7.901977752380e-04;
cov_c0[8] = 1.306463534393e-03;
cov_c0[0] = 0.018729;
cov_c0[1] = 0.00683308;
cov_c0[2] = 0.00271096;
cov_c0[3] = 0.00683308;
cov_c0[4] = 0.00614827;
cov_c0[5] = 0.00133768;
cov_c0[6] = 0.00271096;
cov_c0[7] = 0.00133768;
cov_c0[8] = 0.00337321;
CHECK_VECTOR_APPROX(a.models[label_a].components[0].covariance, cov_c0);
}

Expand Down Expand Up @@ -192,20 +192,20 @@ TEST_CASE("Training with MultithreadingMode::Background", "[GMM]") {
}
// std::cout << std::endl;
std::vector<float> mixtureCoeffs(3);
mixtureCoeffs[0] = 3.819443583488e-01;
mixtureCoeffs[1] = 3.171715140343e-01;
mixtureCoeffs[2] = 3.008841276169e-01;
mixtureCoeffs[0] = 0.410568;
mixtureCoeffs[1] = 0.309933;
mixtureCoeffs[2] = 0.2795;
CHECK_VECTOR_APPROX(a.models[label_a].mixture_coeffs, mixtureCoeffs);
std::vector<double> cov_c0(9);
cov_c0[0] = 1.398498568044e-02;
cov_c0[1] = 5.041130937517e-03;
cov_c0[2] = 1.792829737244e-03;
cov_c0[3] = 5.041130937517e-03;
cov_c0[4] = 3.113048333532e-03;
cov_c0[5] = 7.901977752380e-04;
cov_c0[6] = 1.792829737244e-03;
cov_c0[7] = 7.901977752380e-04;
cov_c0[8] = 1.306463534393e-03;
cov_c0[0] = 0.018729;
cov_c0[1] = 0.00683308;
cov_c0[2] = 0.00271096;
cov_c0[3] = 0.00683308;
cov_c0[4] = 0.00614827;
cov_c0[5] = 0.00133768;
cov_c0[6] = 0.00271096;
cov_c0[7] = 0.00133768;
cov_c0[8] = 0.00337321;
CHECK_VECTOR_APPROX(a.models[label_a].components[0].covariance, cov_c0);
a.reset();
std::vector<double> log_likelihood(100, 0.0);
Expand Down Expand Up @@ -253,32 +253,3 @@ TEST_CASE("Cancel Training", "[GMM]") {
a.cancelTraining();
CHECK(a.size() == 2);
}

// TEST_CASE( "Delete Training Set during Training", "[GMM]" ) {
// for (auto mode : {xmm::MultithreadingMode::Background,
// xmm::MultithreadingMode::Parallel, xmm::MultithreadingMode::Sequential}) {
// xmm::TrainingSet *ts = new xmm::TrainingSet(true, false, 3);
// std::vector<float> observation(3);
// ts->addPhrase(0);
// ts->addPhrase(1);
// for (unsigned int i=0; i<10000; i++) {
// observation[0] = float(i)/10000.;
// observation[1] = pow(float(i)/10000., 2.);
// observation[2] = pow(float(i)/10000., 3.);
// ts->getPhrase(0)->record(observation);
// ts->getPhrase(1)->record(observation);
// }
// std::string label_a(static_cast<std::string>("a"));
// std::string label_b(static_cast<std::string>("b"));
// ts->getPhrase(0)->label.set(label_a);
// ts->getPhrase(1)->label.set(label_b);
// xmm::GMM a;
// MyTrainingListener *listener = new MyTrainingListener();
// a.training_events.addListener(listener);
// a.configuration.gaussians.set(30);
// a.configuration.multithreading = mode;
// a.train(ts);
// delete ts;
// a.joinTraining();
// }
//}

0 comments on commit 699f8ac

Please sign in to comment.