[mlpack] 160/324: Use bool instead of int for tracking convergence.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:22:06 UTC 2014


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

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

commit 13f3025df56c80843835563583eac188d5cff5a2
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Wed Jul 9 19:45:53 2014 +0000

    Use bool instead of int for tracking convergence.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16799 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 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

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