[mlpack-git] master: Add simple test that to ensure the batch size isn't zero. (6359987)

gitdub at mlpack.org gitdub at mlpack.org
Fri Apr 1 11:57:25 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/9e4e126589d19ddbaaaebec256c77d1f3eb75ce2...6359987ecb0cbf762dc2b2167e574ae595a120d8

>---------------------------------------------------------------

commit 6359987ecb0cbf762dc2b2167e574ae595a120d8
Author: marcus <marcus.edel at fu-berlin.de>
Date:   Fri Apr 1 17:57:09 2016 +0200

    Add simple test that to ensure the batch size isn't zero.


>---------------------------------------------------------------

6359987ecb0cbf762dc2b2167e574ae595a120d8
 src/mlpack/tests/minibatch_sgd_test.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/mlpack/tests/minibatch_sgd_test.cpp b/src/mlpack/tests/minibatch_sgd_test.cpp
index cafff50..90e5b58 100644
--- a/src/mlpack/tests/minibatch_sgd_test.cpp
+++ b/src/mlpack/tests/minibatch_sgd_test.cpp
@@ -131,4 +131,27 @@ BOOST_AUTO_TEST_CASE(LogisticRegressionTest)
   }
 }
 
+/**
+ * Run mini-batch SGD on a simple test function and make sure the last batch
+ * size is handled correctly.
+ *
+ * When using a batchsize that fulfilled the constraint:
+ * (numFunctions % batchSize) == 1 we have to make sure that the last batch size
+ * isn't zero.
+ */
+BOOST_AUTO_TEST_CASE(ZeroBatchSizeTest)
+{
+  // Create the generalized Rosenbrock function.
+  GeneralizedRosenbrockFunction f(10);
+
+  MiniBatchSGD<GeneralizedRosenbrockFunction> s(
+      f, f.NumFunctions() - 1, 0.01, 3);
+
+  arma::mat coordinates = f.GetInitialPoint();
+  s.Optimize(coordinates);
+
+  const bool finite = coordinates.is_finite();
+  BOOST_REQUIRE_EQUAL(finite, true);
+}
+
 BOOST_AUTO_TEST_SUITE_END();




More information about the mlpack-git mailing list