[mlpack-git] master: Handle negative gradient values correctly. (f17f8b0)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:04:23 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit f17f8b0cf2deb946e80ff31d9628a221d273853f
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Dec 2 18:25:46 2014 +0000

    Handle negative gradient values correctly.


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

f17f8b0cf2deb946e80ff31d9628a221d273853f
 src/mlpack/tests/regularized_svd_test.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/tests/regularized_svd_test.cpp b/src/mlpack/tests/regularized_svd_test.cpp
index 06e9e8c..1cbb741 100644
--- a/src/mlpack/tests/regularized_svd_test.cpp
+++ b/src/mlpack/tests/regularized_svd_test.cpp
@@ -176,12 +176,12 @@ BOOST_AUTO_TEST_CASE(RegularizedSVDFunctionGradient)
       parameters(i, j) += epsilon;
 
       // Compare numerical and backpropagation gradient values.
-      if (gradient1(i, j) <= 1e-6)
+      if (std::abs(gradient1(i, j)) <= 1e-6)
         BOOST_REQUIRE_SMALL(numGradient1, 1e-5);
       else
         BOOST_REQUIRE_CLOSE(numGradient1, gradient1(i, j), 1e-2);
 
-      if (gradient2(i, j) <= 1e-6)
+      if (std::abs(gradient2(i, j)) <= 1e-6)
         BOOST_REQUIRE_SMALL(numGradient2, 1e-5);
       else
         BOOST_REQUIRE_CLOSE(numGradient2, gradient2(i, j), 1e-2);



More information about the mlpack-git mailing list