[mlpack-git] master: Rename iter -> maxIterations. (980b66c)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Sep 11 07:52:55 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/a4d2dc275f6bdc74898386405decc91f072b2465...a33bc45442b3ce8830ea1a3e930c89d05c6dc9c6

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

commit 980b66c059e19f56dcf63601512d5af674e0c436
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Sep 4 18:11:06 2015 +0000

    Rename iter -> maxIterations.


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

980b66c059e19f56dcf63601512d5af674e0c436
 src/mlpack/methods/perceptron/perceptron.hpp      |  6 +++---
 src/mlpack/methods/perceptron/perceptron_impl.hpp | 13 ++++++-------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/mlpack/methods/perceptron/perceptron.hpp b/src/mlpack/methods/perceptron/perceptron.hpp
index fd674c6..ef0d3c6 100644
--- a/src/mlpack/methods/perceptron/perceptron.hpp
+++ b/src/mlpack/methods/perceptron/perceptron.hpp
@@ -43,7 +43,7 @@ class Perceptron
    */
   Perceptron(const MatType& data,
              const arma::Row<size_t>& labels,
-             const int iterations);
+             const int maxIterations);
 
   /**
    * Classification function. After training, use the weights matrix to
@@ -77,8 +77,8 @@ class Perceptron
   void Serialize(Archive& ar, const unsigned int /* version */);
 
 private:
-  //! To store the number of iterations
-  size_t iter;
+  //! The maximum number of iterations during training.
+  size_t maxIterations;
 
   /**
    * Stores the weights for each of the input class labels.  Each column
diff --git a/src/mlpack/methods/perceptron/perceptron_impl.hpp b/src/mlpack/methods/perceptron/perceptron_impl.hpp
index 72b720a..641e001 100644
--- a/src/mlpack/methods/perceptron/perceptron_impl.hpp
+++ b/src/mlpack/methods/perceptron/perceptron_impl.hpp
@@ -19,7 +19,7 @@ namespace perceptron {
  *
  * @param data Input, training data.
  * @param labels Labels of dataset.
- * @param iterations Maximum number of iterations for the perceptron learning
+ * @param maxIterations Maximum number of iterations for the perceptron learning
  *      algorithm.
  */
 template<
@@ -30,13 +30,13 @@ template<
 Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
     const MatType& data,
     const arma::Row<size_t>& labels,
-    const int iterations)
+    const int maxIterations) :
+    maxIterations(maxIterations)
 {
   WeightInitializationPolicy WIP;
   WIP.Initialize(weights, biases, data.n_rows, arma::max(labels) + 1);
 
   // Start training.
-  iter = iterations;
   Train(data, labels);
 }
 
@@ -89,10 +89,9 @@ Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
     const Perceptron<>& other,
     const MatType& data,
     const arma::rowvec& D,
-    const arma::Row<size_t>& labels)
+    const arma::Row<size_t>& labels) :
+    maxIterations(other.maxIterations)
 {
-  iter = other.iter;
-
   // Insert a row of ones at the top of the training data set.
   WeightInitializationPolicy WIP;
   WIP.Initialize(weights, biases, data.n_rows, arma::max(labels) + 1);
@@ -137,7 +136,7 @@ void Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Train(
 
   const bool hasWeights = (D.n_elem > 0);
 
-  while ((i < iter) && (!converged))
+  while ((i < maxIterations) && (!converged))
   {
     // This outer loop is for each iteration, and we use the 'converged'
     // variable for noting whether or not convergence has been reached.



More information about the mlpack-git mailing list