[mlpack-git] master: Add serialization test for SoftmaxRegression. (754bf15)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Tue Sep 29 09:34:02 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/cbeb3ea17262b7c5115247dc217e316c529249b7...f85a9b22f3ce56143943a2488c05c2810d6b2bf3
>---------------------------------------------------------------
commit 754bf1596db7db3eeb445f32a0ae1865788ff986
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Sep 28 17:25:31 2015 -0400
Add serialization test for SoftmaxRegression.
>---------------------------------------------------------------
754bf1596db7db3eeb445f32a0ae1865788ff986
src/mlpack/tests/serialization_test.cpp | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/mlpack/tests/serialization_test.cpp b/src/mlpack/tests/serialization_test.cpp
index 773b70e..ac91561 100644
--- a/src/mlpack/tests/serialization_test.cpp
+++ b/src/mlpack/tests/serialization_test.cpp
@@ -25,6 +25,7 @@
#include <mlpack/methods/perceptron/perceptron.hpp>
#include <mlpack/methods/logistic_regression/logistic_regression.hpp>
#include <mlpack/methods/neighbor_search/neighbor_search.hpp>
+#include <mlpack/methods/softmax_regression/softmax_regression.hpp>
using namespace mlpack;
using namespace mlpack::distribution;
@@ -799,4 +800,27 @@ BOOST_AUTO_TEST_CASE(AllkNNTest)
CheckMatrices(neighbors, xmlNeighbors, textNeighbors, binaryNeighbors);
}
+BOOST_AUTO_TEST_CASE(SoftmaxRegressionTest)
+{
+ using regression::SoftmaxRegression;
+
+ arma::mat dataset = arma::randu<arma::mat>(5, 1000);
+ arma::vec labels(1000);
+ for (size_t i = 0; i < 500; ++i)
+ labels[i] = 0.0;
+ for (size_t i = 500; i < 1000; ++i)
+ labels[i] = 1.0;
+
+ SoftmaxRegression<> sr(dataset, labels, dataset.n_rows, 2);
+
+ SoftmaxRegression<> srXml(dataset.n_rows, 2);
+ SoftmaxRegression<> srText(dataset.n_rows, 2);
+ SoftmaxRegression<> srBinary(dataset.n_rows, 2);
+
+ SerializeObjectAll(sr, srXml, srText, srBinary);
+
+ CheckMatrices(sr.Parameters(), srXml.Parameters(), srText.Parameters(),
+ srBinary.Parameters());
+}
+
BOOST_AUTO_TEST_SUITE_END();
More information about the mlpack-git
mailing list