Skip to content

Commit

Permalink
speed up examples
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Jul 3, 2012
1 parent a73124b commit 665be2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/undocumented/libshogun/statistics_linear_time_mmd.cpp
Expand Up @@ -68,6 +68,7 @@ void test_linear_mmd_random()
float64_t sigma=2;

index_t num_runs=100;
num_runs=10; //speed up
SGVector<float64_t> mmds(num_runs);

SGMatrix<float64_t> data(dimension, 2*m);
Expand Down Expand Up @@ -108,6 +109,7 @@ void test_linear_mmd_variance_estimate()
float64_t sigma=2;

index_t num_runs=100;
num_runs=10; //speed up
SGVector<float64_t> vars(num_runs);

SGMatrix<float64_t> data(dimension, 2*m);
Expand Down Expand Up @@ -144,6 +146,7 @@ void test_linear_mmd_variance_estimate_vs_bootstrap()
{
index_t dimension=3;
index_t m=50000;
m=1000; //speed up
float64_t difference=0.5;
float64_t sigma=2;

Expand All @@ -156,6 +159,9 @@ void test_linear_mmd_variance_estimate_vs_bootstrap()

CLinearTimeMMD* mmd=new CLinearTimeMMD(kernel, features, m);

/* for checking results, set to 100 */
mmd->set_bootstrap_iterations(100);
mmd->set_bootstrap_iterations(10); // speed up
SGVector<float64_t> null_samples=mmd->bootstrap_null();
float64_t bootstrap_variance=CStatistics::variance(null_samples);
float64_t estimated_variance=mmd->compute_variance_estimate();
Expand All @@ -181,6 +187,7 @@ void test_linear_mmd_type2_error()
float64_t sigma=2;

index_t num_runs=500;
num_runs=50; // speed up
index_t num_errors=0;

SGMatrix<float64_t> data(dimension, 2*m);
Expand Down Expand Up @@ -224,6 +231,10 @@ int main(int argc, char** argv)
{
init_shogun_with_defaults();

/* all tests have been "speed up" by reducing the number of runs/samples.
* If you have any doubts in the results, set all num_runs to original
* numbers and activate asserts. If they fail, something is wrong.
*/
test_linear_mmd_fixed();
test_linear_mmd_random();
test_linear_mmd_variance_estimate();
Expand Down
Expand Up @@ -71,6 +71,7 @@ void test_quadratic_mmd_bootstrap()
float64_t difference=0.5;
float64_t sigma=2;
index_t num_iterations=1000;
num_iterations=10; //speed up

SGMatrix<float64_t> data(dimension, 2*m);
create_mean_data(data, difference);
Expand Down Expand Up @@ -121,6 +122,7 @@ void test_quadratic_mmd_spectrum()
CQuadraticTimeMMD* mmd=new CQuadraticTimeMMD(kernel, features, m);

mmd->set_num_samples_sepctrum(1000);
mmd->set_num_samples_sepctrum(10); //speed up
mmd->set_num_eigenvalues_spectrum(m);
mmd->set_null_approximation_method(MMD2_SPECTRUM);
mmd->set_statistic_type(BIASED);
Expand Down Expand Up @@ -179,6 +181,7 @@ void test_quadratic_mmd_random()
float64_t sigma=2;

index_t num_runs=100;
num_runs=10; //speed up
SGVector<float64_t> mmds(num_runs);

SGMatrix<float64_t> data(dimension, 2*m);
Expand Down Expand Up @@ -211,6 +214,10 @@ int main(int argc, char** argv)
{
init_shogun_with_defaults();

/* all tests have been "speed up" by reducing the number of runs/samples.
* If you have any doubts in the results, set all num_runs to original
* numbers and activate asserts. If they fail, something is wrong. */

test_quadratic_mmd_fixed();
test_quadratic_mmd_random();
test_quadratic_mmd_bootstrap();
Expand Down

0 comments on commit 665be2b

Please sign in to comment.