[mlpack-git] master,mlpack-1.0.x: Fix some formatting issues; no functionality change. (d961238)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:52:26 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 d96123846a1938adc6c826a4642ff9e287cb109c
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Jul 9 19:45:31 2014 +0000

    Fix some formatting issues; no functionality change.


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

d96123846a1938adc6c826a4642ff9e287cb109c
 .../learning_policies/simple_weight_update.hpp     | 70 ++++++++++++----------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/src/mlpack/methods/perceptron/learning_policies/simple_weight_update.hpp b/src/mlpack/methods/perceptron/learning_policies/simple_weight_update.hpp
index 893ed0d..0ab6086 100644
--- a/src/mlpack/methods/perceptron/learning_policies/simple_weight_update.hpp
+++ b/src/mlpack/methods/perceptron/learning_policies/simple_weight_update.hpp
@@ -1,52 +1,56 @@
-/*
- *  @file: SimpleWeightUpdate.hpp
- *  @author: Udit Saxena
+/**
+ * @file simple_weight_update.hpp
+ * @author Udit Saxena
  *
+ * Simple weight update rule for the perceptron.
  */
-
-#ifndef _MLPACK_METHOD_PERCEPTRON_LEARN_SIMPLEWEIGHTUPDATE
-#define _MLPACK_METHOD_PERCEPTRON_LEARN_SIMPLEWEIGHTUPDATE
+#ifndef _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
+#define _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
 
 #include <mlpack/core.hpp>
-/*
-This class is used to update the weightVectors matrix according to 
-the simple update rule as discussed by Rosenblatt:
-  if a vector x has been incorrectly classified by a weight w, 
-  then w = w - x
-  and  w'= w'+ x
-  where w' is the weight vector which correctly classifies x.
-*/
+
+/**
+ * This class is used to update the weightVectors matrix according to the simple
+ * update rule as discussed by Rosenblatt:
+ *
+ *  if a vector x has been incorrectly classified by a weight w,
+ *  then w = w - x
+ *  and  w'= w'+ x
+ *
+ *  where w' is the weight vector which correctly classifies x.
+ */
 namespace mlpack {
 namespace perceptron {
 
 class SimpleWeightUpdate
 {
-public:
-  SimpleWeightUpdate()
-  { }
-  /*
-  This function is called to update the weightVectors matrix. 
-  It decreases the weights of the incorrectly classified class while
-  increasing the weight of the correct class it should have been classified to.
-  
-  @param: trainData - the training dataset.
-  @param: weightVectors - matrix of weight vectors.
-  @param: rowIndex - index of the row which has been incorrectly predicted.
-  @param: labelIndex - index of the vector in trainData.
-  @param: vectorIndex - index of the class which should have been predicted.
- */
-  void UpdateWeights(const arma::mat& trainData, arma::mat& weightVectors,
-                     size_t labelIndex, size_t vectorIndex, size_t rowIndex )
+ public:
+  /**
+   * This function is called to update the weightVectors matrix.
+   *  It decreases the weights of the incorrectly classified class while
+   * increasing the weight of the correct class it should have been classified to.
+   *
+   * @param trainData The training dataset.
+   * @param weightVectors Matrix of weight vectors.
+   * @param rowIndex Index of the row which has been incorrectly predicted.
+   * @param labelIndex Index of the vector in trainData.
+   * @param vectorIndex Index of the class which should have been predicted.
+   */
+  void UpdateWeights(const arma::mat& trainData,
+                     arma::mat& weightVectors,
+                     const size_t labelIndex,
+                     const size_t vectorIndex,
+                     const size_t rowIndex)
   {
     arma::mat instance = trainData.col(labelIndex);
 
-    weightVectors.row(rowIndex) = weightVectors.row(rowIndex) - 
-                               instance.t();
+    weightVectors.row(rowIndex) = weightVectors.row(rowIndex) - instance.t();
 
     weightVectors.row(vectorIndex) = weightVectors.row(vectorIndex) +
-                                 instance.t();
+        instance.t();
   }
 };
+
 }; // namespace perceptron
 }; // namespace mlpack
 



More information about the mlpack-git mailing list