From 6914e7b69d62c9bf8246400aab4f534229dc3799 Mon Sep 17 00:00:00 2001 From: RishabhGarg108 Date: Wed, 11 Nov 2020 00:19:34 +0530 Subject: [PATCH] Made the spacing and columns consistent --- src/mlpack/core/math/columns_to_blocks.hpp | 8 +- src/mlpack/tests/binarize_test.cpp | 6 +- src/mlpack/tests/convolution_test.cpp | 132 ++++++++--------- src/mlpack/tests/cv_test.cpp | 8 +- src/mlpack/tests/decision_stump_test.cpp | 62 ++++---- src/mlpack/tests/det_test.cpp | 138 +++++++++--------- src/mlpack/tests/distribution_test.cpp | 8 +- src/mlpack/tests/facilities_test.cpp | 6 +- src/mlpack/tests/linear_regression_test.cpp | 8 +- src/mlpack/tests/logistic_regression_test.cpp | 6 +- src/mlpack/tests/lsh_test.cpp | 26 ++-- .../main_tests/logistic_regression_test.cpp | 30 ++-- .../tests/main_tests/perceptron_test.cpp | 10 +- src/mlpack/tests/maximal_inputs_test.cpp | 18 ++- src/mlpack/tests/perceptron_test.cpp | 56 +++---- src/mlpack/tests/recurrent_network_test.cpp | 18 +-- 16 files changed, 271 insertions(+), 269 deletions(-) diff --git a/src/mlpack/core/math/columns_to_blocks.hpp b/src/mlpack/core/math/columns_to_blocks.hpp index de482ee573..1b94a20679 100644 --- a/src/mlpack/core/math/columns_to_blocks.hpp +++ b/src/mlpack/core/math/columns_to_blocks.hpp @@ -66,10 +66,10 @@ namespace math { * @code * // This matrix has two columns. * arma::mat input; - * input << -1.0000 << 0.1429 << arma::endr - * << -0.7143 << 0.4286 << arma::endr - * << -0.4286 << 0.7143 << arma::endr - * << -0.1429 << 1.0000 << arma::endr; + * input = { {-1.0000, 0.1429}, + * {-0.7143, 0.4286}, + * {-0.4286, 0.7143}, + * {-0.1429, 1.0000} }; * * arma::mat output; * ColumnsToBlocks ctb(1, 2); diff --git a/src/mlpack/tests/binarize_test.cpp b/src/mlpack/tests/binarize_test.cpp index ba17f31787..f90fb0ad19 100644 --- a/src/mlpack/tests/binarize_test.cpp +++ b/src/mlpack/tests/binarize_test.cpp @@ -46,9 +46,9 @@ TEST_CASE("BinarizeOneDimension", "[BinarizeTest]") TEST_CASE("BinerizeAll", "[BinarizeTest]") { mat input; - input = { {1, 2, 3}, - {4, 5, 6}, // this row will be tested - {7, 8, 9} }; + input = { { 1, 2, 3 }, + { 4, 5, 6 }, // this row will be tested + { 7, 8, 9 } }; mat output; const double threshold = 5.0; diff --git a/src/mlpack/tests/convolution_test.cpp b/src/mlpack/tests/convolution_test.cpp index 7a579568bf..02d3cd800d 100644 --- a/src/mlpack/tests/convolution_test.cpp +++ b/src/mlpack/tests/convolution_test.cpp @@ -124,17 +124,17 @@ TEST_CASE("ValidConvolution2DTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {0, 1, 0}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 0, 1, 0 }, + { -1, 0, 1 } }; - output = { {-3, -2}, - {8, -3} }; + output = { { -3, -2 }, + { 8, -3 } }; // Perform the naive convolution approach. Convolution2DMethodTest >(input, filter, @@ -157,21 +157,21 @@ TEST_CASE("FullConvolution2DTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {1, 1, 1}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 1, 1, 1 }, + { -1, 0, 1 } }; - output = { {1, 2, 2, 2, -3, -4}, - {5, 4, 4, 11, 5, 1}, - {6, 7, 3, 2, 7, 5}, - {1, 9, 12, 3, 1, 4}, - {-1, 1, 11, 10, 6, 3}, - {-2, -3, -2, 2, 4, 1} }; + output = { { 1, 2, 2, 2, -3, -4 }, + { 5, 4, 4, 11, 5, 1 }, + { 6, 7, 3, 2, 7, 5 }, + { 1, 9, 12, 3, 1, 4 }, + { -1, 1, 11, 10, 6, 3 }, + { -2, -3, -2, 2, 4, 1 } }; // Perform the naive convolution approach. Convolution2DMethodTest >(input, filter, @@ -194,17 +194,17 @@ TEST_CASE("ValidConvolution3DTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {0, 1, 0}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 0, 1, 0 }, + { -1, 0, 1 } }; - output = { {-3, -2}, - {8, -3} }; + output = { { -3, -2 }, + { 8, -3 } }; arma::cube inputCube(input.n_rows, input.n_cols, 2); inputCube.slice(0) = input; @@ -239,21 +239,21 @@ TEST_CASE("FullConvolution3DTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {1, 1, 1}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 1, 1, 1 }, + { -1, 0, 1 } }; - output = { {1, 2, 2, 2, -3, -4}, - {5, 4, 4, 11, 5, 1}, - {6, 7, 3, 2, 7, 5}, - {1, 9, 12, 3, 1, 4}, - {-1, 1, 11, 10, 6, 3}, - {-2, -3, -2, 2, 4, 1} }; + output = { { 1, 2, 2, 2, -3, -4 }, + { 5, 4, 4, 11, 5, 1 }, + { 6, 7, 3, 2, 7, 5 }, + { 1, 9, 12, 3, 1, 4 }, + { -1, 1, 11, 10, 6, 3 }, + { -2, -3, -2, 2, 4, 1 } }; arma::cube inputCube(input.n_rows, input.n_cols, 2); inputCube.slice(0) = input; @@ -289,17 +289,17 @@ TEST_CASE("ValidConvolutionBatchTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {0, 1, 0}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 0, 1, 0 }, + { -1, 0, 1 } }; - output = { {-3, -2}, - {8, -3} }; + output = { { -3, -2 }, + { 8, -3 } }; arma::cube filterCube(filter.n_rows, filter.n_cols, 2); filterCube.slice(0) = filter; @@ -331,21 +331,21 @@ TEST_CASE("FullConvolutionBatchTest", "[ConvolutionTest]") { // Generate dataset for convolution function tests. arma::mat input, filter, output; - input = { {1, 2, 3, 4}, - {4, 1, 2, 3}, - {3, 4, 1, 2}, - {2, 3, 4, 1} }; + input = { { 1, 2, 3, 4 }, + { 4, 1, 2, 3 }, + { 3, 4, 1, 2 }, + { 2, 3, 4, 1 } }; - filter = { {1, 0, -1}, - {1, 1, 1}, - {-1, 0, 1} }; + filter = { { 1, 0, -1 }, + { 1, 1, 1 }, + { -1, 0, 1 } }; - output = { {1, 2, 2, 2, -3, -4}, - {5, 4, 4, 11, 5, 1}, - {6, 7, 3, 2, 7, 5}, - {1, 9, 12, 3, 1, 4}, - {-1, 1, 11, 10, 6, 3}, - {-2, -3, -2, 2, 4, 1} }; + output = { { 1, 2, 2, 2, -3, -4 }, + { 5, 4, 4, 11, 5, 1 }, + { 6, 7, 3, 2, 7, 5 }, + { 1, 9, 12, 3, 1, 4 }, + { -1, 1, 11, 10, 6, 3 }, + { -2, -3, -2, 2, 4, 1 } }; arma::cube filterCube(filter.n_rows, filter.n_cols, 2); filterCube.slice(0) = filter; diff --git a/src/mlpack/tests/cv_test.cpp b/src/mlpack/tests/cv_test.cpp index a611ce2d4b..d053d46f4a 100644 --- a/src/mlpack/tests/cv_test.cpp +++ b/src/mlpack/tests/cv_test.cpp @@ -750,10 +750,10 @@ TEST_CASE("KFoldCVWithDTTestUnevenBinsWeighted", "[CVTest]") TEST_CASE("SilhouetteScoreTest", "[CVTest]") { arma::mat X; - X = { {0, 1, 1, 0, 0}, - {0, 1, 2, 0, 0}, - {1, 1, 3, 2, 0} }; - arma::Row labels = {0, 1, 2, 0, 0}; + X = { { 0, 1, 1, 0, 0 }, + { 0, 1, 2, 0, 0 }, + { 1, 1, 3, 2, 0 } }; + arma::Row labels = { 0, 1, 2, 0, 0 }; metric::EuclideanDistance metric; double silhouetteScore = SilhouetteScore::Overall(X, labels, metric); REQUIRE(silhouetteScore == Approx(0.1121684822489150).epsilon(1e-7)); diff --git a/src/mlpack/tests/decision_stump_test.cpp b/src/mlpack/tests/decision_stump_test.cpp index debdf1586f..d9d633fe3e 100644 --- a/src/mlpack/tests/decision_stump_test.cpp +++ b/src/mlpack/tests/decision_stump_test.cpp @@ -30,16 +30,16 @@ TEST_CASE("OneClass", "[DecisionStumpTest]") const size_t inpBucketSize = 6; mat trainingData; - trainingData = { {2.4, 3.8, 3.8}, - {1, 1, 2}, - {1.3, 1.9, 1.3} }; + trainingData = { { 2.4, 3.8, 3.8 }, + { 1, 1, 2 }, + { 1.3, 1.9, 1.3 } }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {1, 1, 1}; + labelsIn = { 1, 1, 1 }; mat testingData; - testingData = {2.4, 2.5, 2.6}; + testingData = { 2.4, 2.5, 2.6 }; DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize); @@ -65,13 +65,13 @@ TEST_CASE("CorrectDimensionChosen", "[DecisionStumpTest]") // found on page 176 (and a description of the correct splitting dimension is // given below that). mat trainingData; - trainingData = { {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2}, - {70, 90, 85, 95, 70, 90, 78, 65, 75, 80, 70, 80, 80, 96}, - {1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0} }; + trainingData = { { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }, + { 70, 90, 85, 95, 70, 90, 78, 65, 75, 80, 70, 80, 80, 96 }, + { 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0 } }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0}; + labelsIn = { 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }; DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize); @@ -92,14 +92,14 @@ TEST_CASE("PerfectSplitOnZero", "[DecisionStumpTest]") const size_t inpBucketSize = 2; mat trainingData; - trainingData = {-1, 1, -2, 2, -3, 3}; + trainingData = { -1, 1, -2, 2, -3, 3 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 1, 0, 1, 0, 1}; + labelsIn = { 0, 1, 0, 1, 0, 1 }; mat testingData; - testingData = {-4, 7, -7, -5, 6}; + testingData = { -4, 7, -7, -5, 6 }; DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize); @@ -123,11 +123,11 @@ TEST_CASE("BinningTesting", "[DecisionStumpTest]") const size_t inpBucketSize = 10; mat trainingData; - trainingData = {-1, 1, -2, 2, -3, 3, -4}; + trainingData = { -1, 1, -2, 2, -3, 3, -4 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 1, 0, 1, 0, 1, 0}; + labelsIn = { 0, 1, 0, 1, 0, 1, 0 }; mat testingData; testingData = {5}; @@ -151,14 +151,14 @@ TEST_CASE("PerfectMultiClassSplit", "[DecisionStumpTest]") const size_t inpBucketSize = 3; mat trainingData; - trainingData = {-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}; + trainingData = { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3}; + labelsIn = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 }; mat testingData; - testingData = {-6.1, -2.1, 1.1, 5.1}; + testingData = { -6.1, -2.1, 1.1, 5.1 }; DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize); @@ -183,16 +183,16 @@ TEST_CASE("MultiClassSplit", "[DecisionStumpTest]") const size_t inpBucketSize = 3; mat trainingData; - trainingData = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10}; + trainingData = { -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2}; + labelsIn = { 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2 }; mat testingData; - testingData = {-6.1, -5.9, -2.1, -0.7, 2.5, 4.7, 7.2, 9.1}; + testingData = { -6.1, -5.9, -2.1, -0.7, 2.5, 4.7, 7.2, 9.1 }; DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize); @@ -320,16 +320,16 @@ TEST_CASE("EmptyConstructorTest", "[DecisionStumpTest]") // Now train on another dataset and make sure something kind of makes sense. mat trainingData; - trainingData = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10}; + trainingData = { -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2}; + labelsIn = { 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2 }; mat testingData; - testingData = {-6.1, -5.9, -2.1, -0.7, 2.5, 4.7, 7.2, 9.1}; + testingData = { -6.1, -5.9, -2.1, -0.7, 2.5, 4.7, 7.2, 9.1 }; DecisionStump<> ds(trainingData, labelsIn.row(0), 4, 3); @@ -354,17 +354,17 @@ TEST_CASE("IntTest", "[DecisionStumpTest]") { // Train on a dataset and make sure something kind of makes sense. imat trainingData; - trainingData = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10}; + trainingData = { -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2}; + labelsIn = { 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2 }; DecisionStump ds(trainingData, labelsIn.row(0), 4, 3); imat testingData; - testingData = {-6, -6, -2, -1, 3, 5, 7, 9}; + testingData = { -6, -6, -2, -1, 3, 5, 7, 9 }; arma::Row predictedLabels; ds.Classify(testingData, predictedLabels); @@ -388,11 +388,11 @@ TEST_CASE("DecisionStumpTrainReturnEntropy", "[DecisionStumpTest]") const size_t inpBucketSize = 2; mat trainingData; - trainingData = {-1, 1, -2, 2, -3, 3}; + trainingData = { -1, 1, -2, 2, -3, 3 }; // No need to normalize labels here. Mat labelsIn; - labelsIn = {0, 1, 0, 1, 0, 1}; + labelsIn = { 0, 1, 0, 1, 0, 1 }; arma::Row weights = arma::ones>(labelsIn.n_elem); diff --git a/src/mlpack/tests/det_test.cpp b/src/mlpack/tests/det_test.cpp index c3f6170c9c..ab55a541cd 100644 --- a/src/mlpack/tests/det_test.cpp +++ b/src/mlpack/tests/det_test.cpp @@ -40,9 +40,9 @@ TEST_CASE("TestGetMaxMinVals", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; DTree tree(testData); @@ -81,11 +81,11 @@ TEST_CASE("TestWithinRange", "[DETTest]") DTree testDTree(maxVals, minVals, 5); arma::vec testQuery(3); - testQuery = {4.5, 2.5, 2}; + testQuery = { 4.5, 2.5, 2 }; REQUIRE(testDTree.WithinRange(testQuery) == true); - testQuery = {8.5, 2.5, 2}; + testQuery = { 8.5, 2.5, 2 }; REQUIRE(testDTree.WithinRange(testQuery) == false); } @@ -94,9 +94,9 @@ TEST_CASE("TestFindSplit", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; DTree testDTree(testData); @@ -124,14 +124,14 @@ TEST_CASE("TestSplitData", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; DTree testDTree(testData); arma::Col oTest(5); - oTest = {1, 2, 3, 4, 5}; + oTest = { 1, 2, 3, 4, 5 }; size_t splitDim = 2; double trueSplitVal = 5.5; @@ -152,10 +152,10 @@ TEST_CASE("TestSparseFindSplit", "[DETTest]") { arma::mat realData(4, 7); - realData = { {.0, 4, 5, 7, 0, 5, 0}, - {.0, 5, 0, 0, 1, 7, 1}, - {.0, 5, 6, 7, 1, 0, 8}, - {-1, 2, 5, 0, 0, 0, 0} }; + realData = { { .0, 4, 5, 7, 0, 5, 0 }, + { .0, 5, 0, 0, 1, 7, 1 }, + { .0, 5, 6, 7, 1, 0, 8 }, + { -1, 2, 5, 0, 0, 0, 0 } }; arma::sp_mat testData(realData); @@ -186,17 +186,17 @@ TEST_CASE("TestSparseSplitData", "[DETTest]") { arma::mat realData(4, 7); - realData = { {.0, 4, 5, 7, 0, 5, 0}, - {.0, 5, 0, 0, 1, 7, 1}, - {.0, 5, 6, 7, 1, 0, 8}, - {-1, 2, 5, 0, 0, 0, 0} }; + realData = { { .0, 4, 5, 7, 0, 5, 0 }, + { .0, 5, 0, 0, 1, 7, 1 }, + { .0, 5, 6, 7, 1, 0, 8 }, + { -1, 2, 5, 0, 0, 0, 0 } }; arma::sp_mat testData(realData); DTree testDTree(testData); arma::Col oTest(7); - oTest = {1, 2, 3, 4, 5, 6, 7}; + oTest = { 1, 2, 3, 4, 5, 6, 7 }; size_t splitDim = 1; double trueSplitVal = .5; @@ -223,12 +223,12 @@ TEST_CASE("TestGrow", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; double rootError, lError, rError, rlError, rrError; @@ -289,9 +289,9 @@ TEST_CASE("TestPruneAndUpdate", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; arma::Col oTest(5); oTest = {0, 1, 2, 3, 4}; @@ -315,19 +315,19 @@ TEST_CASE("TestComputeValue", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; arma::vec q1(3), q2(3), q3(3), q4(3); - q1 = {4, 2, 2}; - q2 = {5, 0.25, 6}; - q3 = {5, 3, 7}; - q4 = {2, 3, 3}; + q1 = { 4, 2, 2 }; + q2 = { 5, 0.25, 6 }; + q3 = { 5, 3, 7 }; + q4 = { 2, 3, 3 }; arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree testDTree(testData); double alpha = testDTree.Grow(testData, oTest, false, 2, 1); @@ -355,9 +355,9 @@ TEST_CASE("TestVariableImportance", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; double rootError, lError, rError, rlError, rrError; @@ -370,7 +370,7 @@ TEST_CASE("TestVariableImportance", "[DETTest]") rrError = -1.0 * exp(2 * log(2.0 / 5.0) - (log(6.5) + log(4.0) + log(2.5))); arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree testDTree(testData); testDTree.Grow(testData, oTest, false, 2, 1); @@ -390,14 +390,14 @@ TEST_CASE("TestSparsePruneAndUpdate", "[DETTest]") { arma::mat realData(3, 5); - realData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + realData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; arma::sp_mat testData(realData); arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree testDTree(testData); double alpha = testDTree.Grow(testData, oTest, false, 2, 1); @@ -419,22 +419,22 @@ TEST_CASE("TestSparseComputeValue", "[DETTest]") { arma::mat realData(3, 5); - realData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + realData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; arma::vec q1d(3), q2d(3), q3d(3), q4d(3); - q1d = {4, 2, 2}; - q2d = {5, 0.25, 6}; - q3d = {5, 3, 7}; - q4d = {2, 3, 3}; + q1d = { 4, 2, 2 }; + q2d = { 5, 0.25, 6 }; + q3d = { 5, 3, 7 }; + q4d = { 2, 3, 3 }; arma::sp_mat testData(realData); arma::sp_vec q1(q1d), q2(q2d), q3(q3d), q4(q4d); arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree testDTree(testData); double alpha = testDTree.Grow(testData, oTest, false, 2, 1); @@ -465,9 +465,9 @@ TEST_CASE("TestTagTree", "[DETTest]") { MatType testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; DTree<>* testDTree = new DTree<>(&testData); @@ -478,9 +478,9 @@ TEST_CASE("TestFindBucket", "[DETTest]") { MatType testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; DTree<>* testDTree = new DTree<>(&testData); @@ -510,13 +510,13 @@ TEST_CASE("CopyConstructorAndOperatorTest", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; // Construct another DTree for testing the children. arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree *testDTree = new DTree(testData); testDTree->Grow(testData, oTest, false, 2, 1); @@ -622,13 +622,13 @@ TEST_CASE("MoveConstructorTest", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; // Construct another DTree for testing the children. arma::Col oTest(5); - oTest = {0, 1, 2, 3, 4}; + oTest = { 0, 1, 2, 3, 4 }; DTree *testDTree = new DTree(testData); testDTree->Grow(testData, oTest, false, 2, 1); @@ -705,9 +705,9 @@ TEST_CASE("MoveOperatorTest", "[DETTest]") { arma::mat testData(3, 5); - testData = { {4, 5, 7, 3, 5}, - {5, 0, 1, 7, 1}, - {5, 6, 7, 1, 8} }; + testData = { { 4, 5, 7, 3, 5 }, + { 5, 0, 1, 7, 1 }, + { 5, 6, 7, 1, 8 } }; // Construct another DTree for testing the children. arma::Col oTest(5); diff --git a/src/mlpack/tests/distribution_test.cpp b/src/mlpack/tests/distribution_test.cpp index 5970277da1..bdb023341f 100644 --- a/src/mlpack/tests/distribution_test.cpp +++ b/src/mlpack/tests/distribution_test.cpp @@ -981,8 +981,8 @@ TEST_CASE("GammaDistributionProbabilityTest", "[DistributionTest]") // Combine into one 2-dimensional distribution. const arma::vec a3("2.0 3.1"), b3("0.9 1.4"); arma::mat x3(2, 2); - x3 = { {2.0, 2.94}, - {2.0, 2.94} }; + x3 = { { 2.0, 2.94 }, + { 2.0, 2.94 } }; arma::vec prob3; // Expect that the 2-dimensional distribution returns the product of the @@ -1017,8 +1017,8 @@ TEST_CASE("GammaDistributionLogProbabilityTest", "[DistributionTest]") // Combine into one 2-dimensional distribution. const arma::vec a3("2.0 3.1"), b3("0.9 1.4"); arma::mat x3(2, 2); - x3 = { {2.0, 2.94}, - {2.0, 2.94} }; + x3 = { { 2.0, 2.94 }, + { 2.0, 2.94 } }; arma::vec logprob3; // Expect that the 2-dimensional distribution returns the product of the diff --git a/src/mlpack/tests/facilities_test.cpp b/src/mlpack/tests/facilities_test.cpp index fa5b651338..b5115dc23f 100644 --- a/src/mlpack/tests/facilities_test.cpp +++ b/src/mlpack/tests/facilities_test.cpp @@ -47,9 +47,9 @@ BOOST_AUTO_TEST_CASE(AssertSizesTest) BOOST_AUTO_TEST_CASE(PairwiseDistanceTest) { arma::mat X; - X = { {0, 1, 1, 0, 0}, - {0, 1, 2, 0, 0}, - {1, 1, 3, 2, 0} }; + X = { { 0, 1, 1, 0, 0 }, + { 0, 1, 2, 0, 0 }, + { 1, 1, 3, 2, 0 } }; metric::EuclideanDistance metric; arma::mat dist = PairwiseDistances(X, metric); BOOST_REQUIRE_EQUAL(dist(0, 0), 0); diff --git a/src/mlpack/tests/linear_regression_test.cpp b/src/mlpack/tests/linear_regression_test.cpp index aea8532905..ae341cb243 100644 --- a/src/mlpack/tests/linear_regression_test.cpp +++ b/src/mlpack/tests/linear_regression_test.cpp @@ -73,8 +73,8 @@ TEST_CASE("LinearRegressionTestCase", "[LinearRegressionTest]") TEST_CASE("ComputeErrorTest", "[LinearRegressionTest]") { arma::mat predictors; - predictors = { {0, 1, 2, 4, 8, 16}, - {16, 8, 4, 2, 1, 0} }; + predictors = { { 0, 1, 2, 4, 8, 16 }, + { 16, 8, 4, 2, 1, 0 } }; arma::rowvec responses = "0 2 4 3 8 8"; // http://www.mlpack.org/trac/ticket/298 @@ -92,8 +92,8 @@ TEST_CASE("ComputeErrorPerfectFitTest", "[LinearRegressionTest]") { // Linear regression should perfectly model this dataset. arma::mat predictors; - predictors = { {0, 1, 2, 1, 6, 2}, - {0, 1, 2, 2, 2, 6} }; + predictors = { { 0, 1, 2, 1, 6, 2 }, + { 0, 1, 2, 2, 2, 6 } }; arma::rowvec responses = "0 2 4 3 8 8"; LinearRegression lr(predictors, responses); diff --git a/src/mlpack/tests/logistic_regression_test.cpp b/src/mlpack/tests/logistic_regression_test.cpp index 3b08619216..ff1ee1820d 100644 --- a/src/mlpack/tests/logistic_regression_test.cpp +++ b/src/mlpack/tests/logistic_regression_test.cpp @@ -1011,9 +1011,9 @@ BOOST_AUTO_TEST_CASE(ConstructionThenTraining) arma::mat myMatrix; // Four points, three dimensions. - myMatrix = { {0.555950, 0.274690, 0.540605, 0.798938}, - {0.948014, 0.973234, 0.216504, 0.883152}, - {0.023787, 0.675382, 0.231751, 0.450332} }; + myMatrix = { { 0.555950, 0.274690, 0.540605, 0.798938 }, + { 0.948014, 0.973234, 0.216504, 0.883152 }, + { 0.023787, 0.675382, 0.231751, 0.450332 } }; arma::Row myTargets("1 0 1 0"); diff --git a/src/mlpack/tests/lsh_test.cpp b/src/mlpack/tests/lsh_test.cpp index 0bdae315dc..48259ad0eb 100644 --- a/src/mlpack/tests/lsh_test.cpp +++ b/src/mlpack/tests/lsh_test.cpp @@ -39,16 +39,16 @@ void GetPointset(const size_t N, arma::mat& rdata) arma::mat c4(d, N / 4, arma::fill::randu); arma::colvec offset1; - offset1 = { {0}, - {3} }; + offset1 = { { 0 }, + { 3 } }; arma::colvec offset2; - offset2 = { {3}, - {3} }; + offset2 = { { 3 }, + { 3 } }; arma::colvec offset4; - offset4 = { {3}, - {0} }; + offset4 = { { 3 }, + { 0 } }; // Spread points in plane. for (size_t p = 0; p < N / 4; ++p) @@ -132,8 +132,8 @@ BOOST_AUTO_TEST_CASE(NumTablesTest) fail = false; const int lSize = 6; // Number of runs. - const int lValue[] = {1, 8, 16, 32, 64, 128}; // Number of tables. - double lValueRecall[lSize] = {0.0}; // Recall of each LSH run. + const int lValue[] = { 1, 8, 16, 32, 64, 128 }; // Number of tables. + double lValueRecall[lSize] = { 0.0 }; // Recall of each LSH run. for (size_t l = 0; l < lSize; ++l) { @@ -198,8 +198,8 @@ BOOST_AUTO_TEST_CASE(HashWidthTest) arma::mat groundDistances; knn.Search(qdata, k, groundTruth, groundDistances); const int hSize = 7; // Number of runs. - const double hValue[] = {0.1, 0.5, 1, 5, 10, 50, 500}; // Hash width. - double hValueRecall[hSize] = {0.0}; // Recall of each run. + const double hValue[] = { 0.1, 0.5, 1, 5, 10, 50, 500 }; // Hash width. + double hValueRecall[hSize] = { 0.0 }; // Recall of each run. for (size_t h = 0; h < hSize; ++h) { @@ -260,8 +260,8 @@ BOOST_AUTO_TEST_CASE(NumProjTest) // LSH test parameters for numProj. const int pSize = 5; // Number of runs. - const int pValue[] = {1, 10, 20, 50, 100}; // Number of projections. - double pValueRecall[pSize] = {0.0}; // Recall of each run. + const int pValue[] = { 1, 10, 20, 50, 100 }; // Number of projections. + double pValueRecall[pSize] = { 0.0 }; // Recall of each run. for (size_t p = 0; p < pSize; ++p) { @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(MultiprobeTest) const size_t repetitions = 5; // Train five objects. const size_t probeTrials = 5; - const size_t numProbes[probeTrials] = {0, 1, 2, 3, 4}; + const size_t numProbes[probeTrials] = { 0, 1, 2, 3, 4 }; // Algorithm parameters. const int k = 4; diff --git a/src/mlpack/tests/main_tests/logistic_regression_test.cpp b/src/mlpack/tests/main_tests/logistic_regression_test.cpp index e81a695bc3..5490da10d4 100644 --- a/src/mlpack/tests/main_tests/logistic_regression_test.cpp +++ b/src/mlpack/tests/main_tests/logistic_regression_test.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(LRNoTrainingData) { arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; SetInputParam("labels", std::move(trainY)); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(LRPridictionSizeCheck) arma::mat trainX = arma::randu(D, N); arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; arma::mat testX = arma::randu(D, M); SetInputParam("training", std::move(trainX)); @@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(LRWrongResponseSizeTest) arma::Row trainY; // Response vector with wrong size. // 8 responses - incorrect size. - trainY = {0, 0, 1, 0, 1, 1, 1, 0}; + trainY = { 0, 0, 1, 0, 1, 1, 1, 0 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(LRModelReload) arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; arma::mat testX = arma::randu(D, M); @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(LRWrongDimOfTestData) arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; // Test data with wrong dimensionality. arma::mat testX = arma::randu(D-1, N); @@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(LRWrongDimOfTestData2) arma::mat trainX = arma::randu(D, N); arma::Row trainY; // 10 responses - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(LRTrainWithMoreThanTwoClasses) arma::Row trainY; // 8 responses containing more than two classes. - trainY = {0, 1, 0, 1, 2, 1, 3, 1}; + trainY = { 0, 1, 0, 1, 2, 1, 3, 1 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -332,7 +332,7 @@ BOOST_AUTO_TEST_CASE(LRNonNegativeMaxIterationTest) arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE(LRNonNegativeStepSizeTest) arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(LRNonNegativeToleranceTest) arma::Row trainY; // 10 responses. - trainY = {1, 1, 0, 1, 0, 0, 0, 1, 0, 1}; + trainY = { 1, 1, 0, 1, 0, 0, 0, 1, 0, 1 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -405,7 +405,7 @@ BOOST_AUTO_TEST_CASE(LRMaxIterationsChangeTest) arma::Row trainY; // 10 responses. - trainY = {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 }; SetInputParam("training", trainX); SetInputParam("labels", trainY); @@ -454,7 +454,7 @@ BOOST_AUTO_TEST_CASE(LRLambdaChangeTest) arma::Row trainY; // 10 responses. - trainY = {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 }; SetInputParam("training", trainX); SetInputParam("labels", trainY); @@ -503,7 +503,7 @@ BOOST_AUTO_TEST_CASE(LRStepSizeChangeTest) arma::Row trainY; // 10 responses. - trainY = {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 }; SetInputParam("training", trainX); SetInputParam("labels", trainY); @@ -554,7 +554,7 @@ BOOST_AUTO_TEST_CASE(LROptimizerChangeTest) arma::Row trainY; // 10 responses. - trainY = {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 }; SetInputParam("training", trainX); SetInputParam("labels", trainY); @@ -606,7 +606,7 @@ BOOST_AUTO_TEST_CASE(LRDecisionBoundaryTest) arma::Row trainY; // 10 responses. - trainY = {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}; + trainY = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 }; arma::mat testX = arma::randu(D, M); diff --git a/src/mlpack/tests/main_tests/perceptron_test.cpp b/src/mlpack/tests/main_tests/perceptron_test.cpp index d29e999cc4..c290c59448 100644 --- a/src/mlpack/tests/main_tests/perceptron_test.cpp +++ b/src/mlpack/tests/main_tests/perceptron_test.cpp @@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(PerceptronReTrainWithWrongClasses) arma::Row labelsX2; // 10 responses. - labelsX2 = {0, 1, 4, 1, 2, 1, 0, 3, 3, 0}; + labelsX2 = { 0, 1, 4, 1, 2, 1, 0, 3, 3, 0 }; // Last column of trainX2 contains the class labels. SetInputParam("training", std::move(trainX2)); @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(PerceptronWrongDimOfTestData) arma::Row trainY; // 10 responses. - trainY = {0 , 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0 , 1, 0, 1, 1, 1, 0, 1, 0, 0 }; // Test data with wrong dimensionality. arma::mat testX = arma::randu(D-3, M); @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(PerceptronWrongResponseSizeTest) arma::Row trainY; // Response vector with wrong size. // 8 responses. - trainY = {0, 0, 1, 0, 1, 1, 1, 0}; + trainY = { 0, 0, 1, 0, 1, 1, 1, 0 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); @@ -395,7 +395,7 @@ BOOST_AUTO_TEST_CASE(PerceptronNoResponsesTest) BOOST_AUTO_TEST_CASE(PerceptronNoTrainingDataTest) { arma::Row trainY; - trainY = {1, 1, 0, 1, 0, 0}; + trainY = { 1, 1, 0, 1, 0, 0 }; SetInputParam("labels", std::move(trainY)); @@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(PerceptronWrongDimOfTestData2) arma::Row trainY; // 10 responses. - trainY = {0, 1, 0, 1, 1, 1, 0, 1, 0, 0}; + trainY = { 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 }; SetInputParam("training", std::move(trainX)); SetInputParam("labels", std::move(trainY)); diff --git a/src/mlpack/tests/maximal_inputs_test.cpp b/src/mlpack/tests/maximal_inputs_test.cpp index 57b6136135..f324f2304a 100644 --- a/src/mlpack/tests/maximal_inputs_test.cpp +++ b/src/mlpack/tests/maximal_inputs_test.cpp @@ -53,10 +53,10 @@ BOOST_AUTO_TEST_CASE(ColumnToBlocksEvaluate) ctb.Transform(CreateMaximalInput(), output); arma::mat matlabResults; - matlabResults = { {-1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -0.42857, -1, 0.14286, 0.71429, -1}, - {-1, -0.71429, -0.14286, -1, 0.42857, 1, -1}, - {-1, -1, -1, -1, -1, -1, -1} }; + matlabResults = { { -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -0.42857, -1, 0.14286, 0.71429, -1 }, + { -1, -0.71429, -0.14286, -1, 0.42857, 1, -1 }, + { -1, -1, -1, -1, -1, -1, -1 } }; TestResults(output, matlabResults); } @@ -71,10 +71,12 @@ BOOST_AUTO_TEST_CASE(ColumnToBlocksChangeBlockSize) ctb.Transform(CreateMaximalInput(), output); arma::mat matlabResults; - matlabResults = { {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3}, - {-3, -1, -0.71429, -0.42857, -0.14286, -3, 0.14286, - 0.42857, 0.71429, 1, -3}, - {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3} }; + matlabResults = { { -3, -3, -3, -3, -3, -3, -3, + -3, -3, -3, -3 }, + { -3, -1, -0.71429, -0.42857, -0.14286, -3, 0.14286, + 0.42857, 0.71429, 1, -3 }, + { -3, -3, -3, -3, -3, -3, -3, + -3, -3, -3, -3 } }; TestResults(output, matlabResults); } diff --git a/src/mlpack/tests/perceptron_test.cpp b/src/mlpack/tests/perceptron_test.cpp index 5039c7fbd6..d53903c259 100644 --- a/src/mlpack/tests/perceptron_test.cpp +++ b/src/mlpack/tests/perceptron_test.cpp @@ -110,16 +110,16 @@ TEST_CASE("SimpleWeightUpdateInstanceWeight", "[PerceptronTest]") TEST_CASE("And", "[PerceptronTest]") { mat trainData; - trainData = { {0, 1, 1, 0}, - {1, 0, 1, 0} }; + trainData = { { 0, 1, 1, 0 }, + { 1, 0, 1, 0 } }; Mat labels; - labels = {0, 0, 1, 0}; + labels = { 0, 0, 1, 0 }; Perceptron<> p(trainData, labels.row(0), 2, 1000); mat testData; - testData = { {0, 1, 1, 0}, - {1, 0, 1, 0} }; + testData = { { 0, 1, 1, 0 }, + { 1, 0, 1, 0 } }; Row predictedLabels(testData.n_cols); p.Classify(testData, predictedLabels); @@ -135,17 +135,17 @@ TEST_CASE("And", "[PerceptronTest]") TEST_CASE("Or", "[PerceptronTest]") { mat trainData; - trainData = { {0, 1, 1, 0}, - {1, 0, 1, 0} }; + trainData = { { 0, 1, 1, 0 }, + { 1, 0, 1, 0 } }; Mat labels; - labels = {1, 1, 1, 0}; + labels = { 1, 1, 1, 0 }; Perceptron<> p(trainData, labels.row(0), 2, 1000); mat testData; - testData = { {0, 1, 1, 0}, - {1, 0, 1, 0} }; + testData = { { 0, 1, 1, 0 }, + { 1, 0, 1, 0 } }; Row predictedLabels(testData.n_cols); p.Classify(testData, predictedLabels); @@ -162,17 +162,17 @@ TEST_CASE("Or", "[PerceptronTest]") TEST_CASE("Random3", "[PerceptronTest]") { mat trainData; - trainData = { {0, 1, 1, 4, 5, 4, 1, 2, 1}, - {1, 0, 1, 1, 1, 2, 4, 5, 4} }; + trainData = { { 0, 1, 1, 4, 5, 4, 1, 2, 1 }, + { 1, 0, 1, 1, 1, 2, 4, 5, 4 } }; Mat labels; - labels = {0, 0, 0, 1, 1, 1, 2, 2, 2}; + labels = { 0, 0, 0, 1, 1, 1, 2, 2, 2 }; Perceptron<> p(trainData, labels.row(0), 3, 1000); mat testData; - testData = { {0, 1, 1}, - {1, 0, 1} }; + testData = { { 0, 1, 1 }, + { 1, 0, 1 } }; Row predictedLabels(testData.n_cols); p.Classify(testData, predictedLabels); @@ -187,17 +187,17 @@ TEST_CASE("Random3", "[PerceptronTest]") TEST_CASE("TwoPoints", "[PerceptronTest]") { mat trainData; - trainData = { {0, 1}, - {1, 0} }; + trainData = { { 0, 1 }, + { 1, 0 } }; Mat labels; - labels = {0, 1}; + labels = { 0, 1 }; Perceptron<> p(trainData, labels.row(0), 2, 1000); mat testData; - testData = { {0, 1}, - {1, 0} }; + testData = { { 0, 1 }, + { 1, 0 } }; Row predictedLabels(testData.n_cols); p.Classify(testData, predictedLabels); @@ -212,17 +212,17 @@ TEST_CASE("TwoPoints", "[PerceptronTest]") TEST_CASE("NonLinearlySeparableDataset", "[PerceptronTest]") { mat trainData; - trainData = { {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8}, - {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2} }; + trainData = { { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 } }; Mat labels; - labels = {0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}; + labels = { 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1 }; Perceptron<> p(trainData, labels.row(0), 2, 1000); mat testData; - testData = { {3, 4, 5, 6}, - {3, 2.3, 1.7, 1.5} }; + testData = { { 3, 4, 5, 6 }, + { 3, 2.3, 1.7, 1.5 } }; Row predictedLabels(testData.n_cols); p.Classify(testData, predictedLabels); @@ -235,11 +235,11 @@ TEST_CASE("NonLinearlySeparableDataset", "[PerceptronTest]") TEST_CASE("SecondaryConstructor", "[PerceptronTest]") { mat trainData; - trainData = { {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8}, - {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2} }; + trainData = { { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 } }; Mat labels; - labels = {0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}; + labels = { 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1 }; Perceptron<> p1(trainData, labels.row(0), 2, 1000); diff --git a/src/mlpack/tests/recurrent_network_test.cpp b/src/mlpack/tests/recurrent_network_test.cpp index 8197fe2dd3..e734d41890 100644 --- a/src/mlpack/tests/recurrent_network_test.cpp +++ b/src/mlpack/tests/recurrent_network_test.cpp @@ -309,7 +309,7 @@ template void ReberReverseTranslation(const MatType& translation, char& symbol) { arma::Col symbols; - symbols = {'B', 'T', 'S', 'X', 'P', 'V', 'E'}; + symbols = { 'B', 'T', 'S', 'X', 'P', 'V', 'E' }; const int idx = arma::as_scalar(arma::find(translation == 1, 1, "first")); symbol = symbols(idx); @@ -324,7 +324,7 @@ void ReberReverseTranslation(const MatType& translation, char& symbol) void ReberTranslation(const char symbol, arma::colvec& translation) { arma::Col symbols; - symbols = {'B', 'T', 'S', 'X', 'P', 'V', 'E'}; + symbols = { 'B', 'T', 'S', 'X', 'P', 'V', 'E' }; const int idx = arma::as_scalar(arma::find(symbols == symbol, 1, "first")); translation = arma::zeros(7); @@ -464,12 +464,12 @@ arma::Mat GenerateReberGrammarData( // Reber state transition matrix. (The last two columns are the indices to the // next path). arma::Mat transitions; - transitions = { {'T', 'P', '1', '2'}, - {'X', 'S', '3', '1'}, - {'V', 'T', '4', '2'}, - {'X', 'S', '2', '5'}, - {'P', 'V', '3', '5'}, - {'E', 'E', '0', '0'} }; + transitions = { { 'T', 'P', '1', '2' }, + { 'X', 'S', '3', '1' }, + { 'V', 'T', '4', '2' }, + { 'X', 'S', '2', '5' }, + { 'P', 'V', '3', '5' }, + { 'E', 'E', '0', '0' } }; std::string trainReber, testReber; @@ -1422,7 +1422,7 @@ TEST_CASE("LargeRhoValueRnnTest", "[RecurrentNetworkTest]") using MatType = arma::cube; std::vectortrainingData = { "THIS IS THE INPUT 0" , "THIS IS THE INPUT 1" , - "THIS IS THE INPUT 3"}; + "THIS IS THE INPUT 3" }; RNN<> model(rho);