[mlpack] 17/44: Backport r17181-17183.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Mon Feb 15 19:35:53 UTC 2016
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to tag mlpack-1.0.11
in repository mlpack.
commit 87009986654546115ebfe07b00ec7953bd21abef
Author: Ryan Curtin <ryan at ratml.org>
Date: Sun Dec 7 19:34:53 2014 +0000
Backport r17181-17183.
---
src/mlpack/core/data/load_impl.hpp | 18 ++++++++++++++++++
src/mlpack/tests/load_save_test.cpp | 4 +++-
src/mlpack/tests/sa_test.cpp | 27 +++++++++++++++++++--------
3 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/src/mlpack/core/data/load_impl.hpp b/src/mlpack/core/data/load_impl.hpp
index caafc17..a995b71 100644
--- a/src/mlpack/core/data/load_impl.hpp
+++ b/src/mlpack/core/data/load_impl.hpp
@@ -157,6 +157,22 @@ bool Load(const std::string& filename,
#ifdef ARMA_USE_HDF5
loadType = arma::hdf5_binary;
stringType = "HDF5 data";
+ #if ARMA_VERSION_MAJOR == 4 && \
+ (ARMA_VERSION_MINOR >= 300 && ARMA_VERSION_MINOR <= 400)
+ Timer::Stop("loading_data");
+ if (fatal)
+ Log::Fatal << "Attempted to load '" << filename << "' as HDF5 data, but "
+ << "Armadillo 4.300.0 through Armadillo 4.400.1 are known to have "
+ << "bugs and one of these versions is in use. Load failed."
+ << std::endl;
+ else
+ Log::Warn << "Attempted to load '" << filename << "' as HDF5 data, but "
+ << "Armadillo 4.300.0 through Armadillo 4.400.1 are known to have "
+ << "bugs and one of these versions is in use. Load failed."
+ << std::endl;
+
+ return false;
+ #endif
#else
Timer::Stop("loading_data");
if (fatal)
@@ -200,6 +216,8 @@ bool Load(const std::string& filename,
Log::Info << "Loading '" << filename << "' as " << stringType << ". "
<< std::flush;
+ Log::Debug << "load type " << loadType << "\n";
+
const bool success = matrix.load(stream, loadType);
if (!success)
diff --git a/src/mlpack/tests/load_save_test.cpp b/src/mlpack/tests/load_save_test.cpp
index f19d528..9eae6c3 100644
--- a/src/mlpack/tests/load_save_test.cpp
+++ b/src/mlpack/tests/load_save_test.cpp
@@ -393,7 +393,9 @@ BOOST_AUTO_TEST_CASE(SavePGMBinaryTest)
remove("test_file.pgm");
}
-#ifdef ARMA_USE_HDF5
+#if defined(ARMA_USE_HDF5) && (ARMA_VERSION_MAJOR == 3 \
+ || (ARMA_VERSION_MAJOR == 4 && (ARMA_VERSION_MINOR < 300 \
+ || ARMA_VERSION_MINOR > 400)))
/**
* Make sure load as HDF5 is successful.
*/
diff --git a/src/mlpack/tests/sa_test.cpp b/src/mlpack/tests/sa_test.cpp
index 1073b77..992da57 100644
--- a/src/mlpack/tests/sa_test.cpp
+++ b/src/mlpack/tests/sa_test.cpp
@@ -42,18 +42,29 @@ BOOST_AUTO_TEST_SUITE(SATest);
BOOST_AUTO_TEST_CASE(GeneralizedRosenbrockTest)
{
+ math::RandomSeed(std::time(NULL));
size_t dim = 50;
GeneralizedRosenbrockFunction f(dim);
- ExponentialSchedule schedule(1e-5);
- SA<GeneralizedRosenbrockFunction, ExponentialSchedule>
- sa(f, schedule, 10000000, 1000., 1000, 100, 1e-9, 3, 20, 0.3, 0.3);
- arma::mat coordinates = f.GetInitialPoint();
- const double result = sa.Optimize(coordinates);
+ double iteration = 0;
+ double result = DBL_MAX;
+ arma::mat coordinates;
+ while (result > 1e-6)
+ {
+ ExponentialSchedule schedule(1e-5);
+ SA<GeneralizedRosenbrockFunction, ExponentialSchedule>
+ sa(f, schedule, 10000000, 1000., 1000, 100, 1e-10, 3, 20, 0.3, 0.3);
+ coordinates = f.GetInitialPoint();
+ result = sa.Optimize(coordinates);
+ ++iteration;
+
+ BOOST_REQUIRE_LT(iteration, 3); // No more than three tries.
+ }
+ // 0.1% tolerance for each coordinate.
BOOST_REQUIRE_SMALL(result, 1e-6);
for (size_t j = 0; j < dim; ++j)
- BOOST_REQUIRE_CLOSE(coordinates[j], (double) 1.0, 1e-2);
+ BOOST_REQUIRE_CLOSE(coordinates[j], (double) 1.0, 0.1);
}
// The Rosenbrock function is a simple function to optimize.
@@ -106,11 +117,11 @@ class RastrigrinFunction
BOOST_AUTO_TEST_CASE(RastrigrinFunctionTest)
{
// Simulated annealing isn't guaranteed to converge (except in very specific
- // situations). If this works 1 of 3 times, I'm fine with that. All I want
+ // situations). If this works 1 of 4 times, I'm fine with that. All I want
// to know is that this implementation will escape from local minima.
size_t successes = 0;
- for (size_t trial = 0; trial < 3; ++trial)
+ for (size_t trial = 0; trial < 4; ++trial)
{
RastrigrinFunction f;
ExponentialSchedule schedule(3e-6);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list