[mlpack-git] master, mlpack-1.0.x: Use bool instead of int for tracking convergence. (0d91b12)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:52:28 EST 2015


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

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 0d91b124492883532552ab2d5d80ff0cc5abb5d0
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Jul 9 19:45:53 2014 +0000

    Use bool instead of int for tracking convergence.


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

0d91b124492883532552ab2d5d80ff0cc5abb5d0
 src/mlpack/methods/perceptron/perceptron_impl.hpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mlpack/methods/perceptron/perceptron_impl.hpp b/src/mlpack/methods/perceptron/perceptron_impl.hpp
index cb63017..08b03c6 100644
--- a/src/mlpack/methods/perceptron/perceptron_impl.hpp
+++ b/src/mlpack/methods/perceptron/perceptron_impl.hpp
@@ -47,7 +47,8 @@ Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
   zOnes.fill(1);
   trainData.insert_rows(0, zOnes);
 
-  int j, i = 0, converged = 0;
+  int j, i = 0;
+  bool converged = false;
   size_t tempLabel;
   arma::uword maxIndexRow, maxIndexCol;
   double maxVal;
@@ -60,7 +61,7 @@ Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
     // This outer loop is for each iteration, and we use the 'converged'
     // variable for noting whether or not convergence has been reached.
     i++;
-    converged = 1;
+    converged = true;
 
     // Now this inner loop is for going through the dataset in each iteration.
     for (j = 0; j < data.n_cols; j++)
@@ -75,7 +76,7 @@ Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
       if (maxIndexRow != classLabels(0, j))
       {
         // Due to incorrect prediction, convergence set to 0.
-        converged = 0;
+        converged = false;
         tempLabel = labels(0, j);
         // Send maxIndexRow for knowing which weight to update, send j to know
         // the value of the vector to update it with.  Send tempLabel to know



More information about the mlpack-git mailing list