[mlpack-svn] r17467 - in mlpack/tags/mlpack-1.0.11: . src/mlpack src/mlpack/core/data src/mlpack/core/math src/mlpack/core/util src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sun Dec 7 14:40:00 EST 2014
Author: rcurtin
Date: Sun Dec 7 14:39:59 2014
New Revision: 17467
Log:
Backport r17390-17395.
Modified:
mlpack/tags/mlpack-1.0.11/ (props changed)
mlpack/tags/mlpack-1.0.11/HISTORY.txt
mlpack/tags/mlpack-1.0.11/src/mlpack/core.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/core/data/load_impl.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/core/math/random.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/core/util/sfinae_utility.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/prereqs.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp
Modified: mlpack/tags/mlpack-1.0.11/HISTORY.txt
==============================================================================
--- mlpack/tags/mlpack-1.0.11/HISTORY.txt (original)
+++ mlpack/tags/mlpack-1.0.11/HISTORY.txt Sun Dec 7 14:39:59 2014
@@ -15,6 +15,9 @@
* Fixes for numerous intermittent test failures.
+ * math::RandomSeed() now sets the random seed for recent (>=3.930) Armadillo
+ versions.
+
2014-08-29 mlpack 1.0.10
* Bugfix for NeighborSearch regression which caused very slow allknn/allkfn.
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/core.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/core.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/core.hpp Sun Dec 7 14:39:59 2014
@@ -193,6 +193,9 @@
#include <mlpack/core/kernels/spherical_kernel.hpp>
#include <mlpack/core/kernels/triangular_kernel.hpp>
+// Use Armadillo's C++ version detection.
+#ifdef ARMA_USE_CXX11
+ #define MLPACK_USE_CX11
#endif
// Clean up unfortunate Windows preprocessor definitions, even if this file was
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/core/data/load_impl.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/core/data/load_impl.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/core/data/load_impl.hpp Sun Dec 7 14:39:59 2014
@@ -216,8 +216,6 @@
Log::Info << "Loading '" << filename << "' as " << stringType << ". "
<< std::flush;
- Log::Debug << "load type " << loadType << "\n";
-
const bool success = matrix.load(stream, loadType);
if (!success)
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/core/math/random.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/core/math/random.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/core/math/random.hpp Sun Dec 7 14:39:59 2014
@@ -64,6 +64,12 @@
{
randGen.seed((uint32_t) seed);
srand((unsigned int) seed);
+#if ARMA_VERSION_MAJOR > 3 || \
+ (ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR >= 930)
+ // Armadillo >= 3.930 has its own random number generator internally that we
+ // need to set the seed for also.
+ arma::arma_rng::set_seed(seed);
+#endif
}
/**
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/core/util/sfinae_utility.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/core/util/sfinae_utility.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/core/util/sfinae_utility.hpp Sun Dec 7 14:39:59 2014
@@ -27,6 +27,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
+#include <mlpack/prereqs.hpp>
/*
* Constructs a template supporting the SFINAE pattern.
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/prereqs.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/prereqs.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/prereqs.hpp Sun Dec 7 14:39:59 2014
@@ -63,4 +63,11 @@
// Now include Armadillo through the special mlpack extensions.
#include <mlpack/core/arma_extend/arma_extend.hpp>
+// On Visual Studio, disable C4519 (default arguments for function templates)
+// since it's by default an error, which doesn't even make any sense because
+// it's part of the C++11 standard.
+#ifdef _MSC_VER
+ #pragma warning(disable : 4519)
+#endif
+
#endif
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp Sun Dec 7 14:39:59 2014
@@ -35,17 +35,16 @@
*/
BOOST_AUTO_TEST_CASE(SVDBatchConvergenceElementTest)
{
- mlpack::math::RandomSeed(10);
sp_mat data;
data.sprandn(1000, 1000, 0.2);
- AMF<SimpleToleranceTermination<sp_mat>,
- RandomInitialization,
+ AMF<SimpleToleranceTermination<sp_mat>,
+ AverageInitialization,
SVDBatchLearning> amf;
- mat m1,m2;
+ mat m1, m2;
amf.Apply(data, 2, m1, m2);
-
- BOOST_REQUIRE_NE(amf.TerminationPolicy().Iteration(),
- amf.TerminationPolicy().MaxIterations());
+
+ BOOST_REQUIRE_NE(amf.TerminationPolicy().Iteration(),
+ amf.TerminationPolicy().MaxIterations());
}
/**
@@ -75,6 +74,8 @@
// Fill sparse matrix.
sp_mat cleanedData = arma::sp_mat(locations, values, maxUserID, maxItemID);
+ // Explicitly setting the random seed forces the random initialization to be
+ // the same. There may be a better way to do this.
mlpack::math::RandomSeed(10);
ValidationRMSETermination<sp_mat> vrt(cleanedData, 2000);
AMF<ValidationRMSETermination<sp_mat>,
@@ -136,7 +137,7 @@
RandomInitialization(),
SVDBatchLearning(0.0009, 0, 0, 0));
- mat m1,m2;
+ mat m1, m2;
double RMSE_1 = amf_1.Apply(cleanedData, 2, m1, m2);
mlpack::math::RandomSeed(10);
@@ -156,17 +157,18 @@
*/
BOOST_AUTO_TEST_CASE(SVDBatchNegativeElementTest)
{
- mat test;
- test.zeros(3,3);
- test(0, 0) = 1;
- test(0, 1) = -2;
- test(0, 2) = 3;
- test(1, 0) = 2;
- test(1, 1) = -1;
- test(1, 2) = 2;
- test(2, 0) = 2;
- test(2, 1) = 2;
- test(2, 2) = 2;
+ math::RandomSeed(std::time(NULL));
+ // Create two 5x3 matrices that we should be able to recover.
+ mat testLeft;
+ testLeft.randu(5, 3);
+ testLeft -= 0.5; // Shift so elements are negative.
+
+ mat testRight;
+ testRight.randu(3, 5);
+ testRight -= 0.5; // Shift so elements are negative.
+
+ // Assemble a rank-3 matrix that is 5x5.
+ mat test = testLeft * testRight;
AMF<SimpleToleranceTermination<mat>,
RandomInitialization,
@@ -174,17 +176,14 @@
RandomInitialization(),
SVDBatchLearning(0.3, 0.001, 0.001, 0));
mat m1, m2;
- amf.Apply(test, 2, m1, m2);
+ amf.Apply(test, 3, m1, m2);
arma::mat result = m1 * m2;
- for(size_t i = 0;i < 3;i++)
- {
- for(size_t j = 0;j < 3;j++)
- {
- BOOST_REQUIRE_LE(abs(test(i,j) - result(i,j)), 0.5);
- }
- }
+ // 5% element-wise tolerance.
+ for (size_t i = 0; i < 3; i++)
+ for (size_t j = 0; j < 3; j++)
+ BOOST_REQUIRE_CLOSE(test(i, j), result(i, j), 5.0);
}
BOOST_AUTO_TEST_SUITE_END();
More information about the mlpack-svn
mailing list