Skip to content

Commit

Permalink
fix the meta test and some confilcts
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeLing committed Jul 19, 2017
1 parent 80f7376 commit b227677
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/meta/generator/translate.py
Expand Up @@ -483,7 +483,7 @@ def translateExpr(self, expr):
method = expr[key][0]["Identifier"]
argsList = None
try:
argsList = expr[key][2]
argsList = expr[key][1]
except IndexError:
pass
translatedArgsList = self.translateArgumentList(argsList)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/clustering/gmm.sg
@@ -1,6 +1,6 @@
CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/clustering/kmeans.sg
@@ -1,5 +1,5 @@
CSVFile f_feats_train("../../data/classifier_binary_2d_linear_features_train.dat")
Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/converter/ica_fast.sg
@@ -1,6 +1,6 @@
CSVFile f_feats("../../data/ica_2_sources.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features(f_feats)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/converter/ica_ff_sep.sg
@@ -1,6 +1,6 @@
CSVFile f_feats("../../data/ica_2_sources.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features(f_feats)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/converter/ica_jade.sg
@@ -1,6 +1,6 @@
CSVFile f_feats("../../data/ica_2_sources.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features(f_feats)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/converter/ica_jedi_sep.sg
@@ -1,6 +1,6 @@
CSVFile f_feats("../../data/ica_2_sources.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features(f_feats)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/converter/ica_sobi.sg
@@ -1,6 +1,6 @@
CSVFile f_feats("../../data/ica_2_sources.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features(f_feats)
Expand Down
Expand Up @@ -2,7 +2,7 @@ CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_4class_2d_linear_labels_test.dat")
Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
4 changes: 3 additions & 1 deletion examples/meta/src/meta_api/calls.sg
@@ -1,9 +1,11 @@
# static call
Math:init_random(1)
# Math:init_random(1)

# global function call
get_global_io()

set_global_seed(1)

# member function call
GaussianKernel k()
k.set_width(1)
2 changes: 1 addition & 1 deletion examples/meta/src/multiclass_classifier/cartree.sg
Expand Up @@ -2,7 +2,7 @@ CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_4class_2d_linear_labels_test.dat")
Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
@@ -1,4 +1,4 @@
Math:init_random(1)
set_global_seed(1)

CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat")
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/multiclass_classifier/random_forest.sg
Expand Up @@ -2,7 +2,7 @@ CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_4class_2d_linear_labels_test.dat")
Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
Expand Up @@ -3,7 +3,7 @@ CSVFile f_feats_test("../../data/classifier_binary_2d_nonlinear_features_test.da
CSVFile f_labels_train("../../data/classifier_binary_2d_nonlinear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_binary_2d_nonlinear_labels_test.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
Expand Up @@ -3,7 +3,7 @@ CSVFile f_feats_test("../../data/regression_1d_sinc_features_test_with_9d_noise.
CSVFile f_labels_train("../../data/regression_1d_sinc_labels_train.dat")
CSVFile f_labels_test("../../data/regression_1d_sinc_labels_test.dat")

Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
2 changes: 1 addition & 1 deletion examples/meta/src/regression/random_forest_regression.sg
Expand Up @@ -2,7 +2,7 @@ CSVFile f_feats_train("../../data/regression_1d_linear_features_train.dat")
CSVFile f_feats_test("../../data/regression_1d_linear_features_test.dat")
CSVFile f_labels_train("../../data/regression_1d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/regression_1d_linear_labels_test.dat")
Math:init_random(1)
set_global_seed(1)

#![create_features]
RealFeatures features_train(f_feats_train)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/environments/RegressionTestEnvironment.h
Expand Up @@ -54,7 +54,7 @@ class RegressionTestEnvironment : public ::testing::Environment
public:
virtual void SetUp()
{
sg_rand->set_seed(57);
set_global_seed(57);

SGMatrix<float64_t> feat_train_data =
CDataGenerator::generate_gaussians(n_train, 1, n_dim);
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/lib/DynamicArray_unittest.cc
Expand Up @@ -62,9 +62,10 @@ TYPED_TEST(CDynamicArrayFixture, set_array)
this->wrapper_array->reset_array();
EXPECT_EQ(this->wrapper_array->get_num_elements(), 0);
TypeParam* array = SG_MALLOC(TypeParam, 5);
auto prng = std::unique_ptr<CRandom>(new CRandom());
for (int32_t i = 0; i < 5; i++)
{
array[i] = (TypeParam)CMath::random(1, 10);
array[i] = (TypeParam)prng->random(1, 10);
}
this->wrapper_array->set_array(array, 5);

Expand All @@ -79,9 +80,10 @@ TYPED_TEST(CDynamicArrayFixture, set_array)
TYPED_TEST(CDynamicArrayFixture, const_set_array)
{
TypeParam* array = SG_MALLOC(TypeParam, 5);
auto prng = std::unique_ptr<CRandom>(new CRandom());
for (int32_t i = 0; i < 5; i++)
{
array[i] = (TypeParam)CMath::random(1, 10);
array[i] = (TypeParam)prng->random(1, 10);
}
const TypeParam* const_array = array;
this->wrapper_array->reset_array();
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/statistical_testing/KernelSelection_unittest.cc
Expand Up @@ -287,7 +287,7 @@ TEST(KernelSelectionMaxCrossValidation, quadratic_time_single_kernel_dense)
mmd->set_train_test_mode(false);

auto selected_kernel=static_cast<CGaussianKernel*>(mmd->get_kernel());
EXPECT_NEAR(selected_kernel->get_width(), 0.03125, 1E-10);
EXPECT_NEAR(selected_kernel->get_width(), 0.125, 1E-10);
}

TEST(KernelSelectionMaxCrossValidation, linear_time_single_kernel_dense)
Expand Down
Expand Up @@ -61,6 +61,7 @@ TEST(CrossValidationMMD, biased_full)
const float64_t difference=0.5;
const float64_t alpha=0.05;
const auto stype=ST_BIASED_FULL;
set_global_seed(12345);

auto gen_p=some<CMeanShiftDataGenerator>(0, dim, 0);
auto gen_q=some<CMeanShiftDataGenerator>(difference, dim, 0);
Expand Down Expand Up @@ -91,7 +92,6 @@ TEST(CrossValidationMMD, biased_full)
cv.m_num_runs=num_runs;
cv.m_rejections=SGMatrix<float64_t>(num_runs*num_folds, num_kernels);

set_global_seed(12345);
cv(kernel_mgr);
kernel_mgr.unset_precomputed_distance();

Expand All @@ -105,7 +105,6 @@ TEST(CrossValidationMMD, biased_full)
permutation_mmd.m_stype=stype;
permutation_mmd.m_num_null_samples=num_null_samples;

set_global_seed(12345);
for (auto k=0; k<num_kernels; ++k)
{
CKernel* kernel=kernel_mgr.kernel_at(k);
Expand Down

0 comments on commit b227677

Please sign in to comment.