[mlpack] 86/149: If gradient2 or gradient1 are zero, then BOOST_REQUIRE_CLOSE will fail, so use BOOST_REQUIRE_SMALL in those situations.

Barak A. Pearlmutter barak+git at pearlmutter.net
Sat May 2 09:11:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit cca2f52e68085ea05bf875adec3f221ca60ffd7d
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Mon Nov 10 16:56:39 2014 +0000

    If gradient2 or gradient1 are zero, then BOOST_REQUIRE_CLOSE will fail, so use
    BOOST_REQUIRE_SMALL in those situations.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17314 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/tests/regularized_svd_test.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/tests/regularized_svd_test.cpp b/src/mlpack/tests/regularized_svd_test.cpp
index 3d35c76..7b03466 100644
--- a/src/mlpack/tests/regularized_svd_test.cpp
+++ b/src/mlpack/tests/regularized_svd_test.cpp
@@ -176,8 +176,15 @@ BOOST_AUTO_TEST_CASE(RegularizedSVDFunctionGradient)
       parameters(i, j) += epsilon;
 
       // Compare numerical and backpropagation gradient values.
-      BOOST_REQUIRE_CLOSE(numGradient1, gradient1(i, j), 1e-2);
-      BOOST_REQUIRE_CLOSE(numGradient2, gradient2(i, j), 1e-2);
+      if (gradient1(i, j) == 0.0)
+        BOOST_REQUIRE_SMALL(numGradient1, 1e-5);
+      else
+        BOOST_REQUIRE_CLOSE(numGradient1, gradient1(i, j), 1e-2);
+
+      if (graident2(i, j) == 0.0)
+        BOOST_REQUIRE_SMALL(numGradient2, 1e-5);
+      else
+        BOOST_REQUIRE_CLOSE(numGradient2, gradient2(i, j), 1e-2);
     }
   }
 }

-- 
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