[mlpack-git] master: make codes follows the style guide (e1320b7)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Tue Sep 29 09:33:51 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/cbeb3ea17262b7c5115247dc217e316c529249b7...f85a9b22f3ce56143943a2488c05c2810d6b2bf3

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

commit e1320b7475a108bf77d0e573a311e49d2e73e35e
Author: stereomatchingkiss <stereomatchingkiss at gmail.com>
Date:   Mon Sep 28 15:14:26 2015 +0800

    make codes follows the style guide


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

e1320b7475a108bf77d0e573a311e49d2e73e35e
 .../softmax_regression_function.cpp                | 26 +++++++++---------
 .../softmax_regression_function.hpp                | 32 ++++++++++++++++------
 2 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp
index 9fb5e64..a63ccf6 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp
@@ -15,11 +15,11 @@ SoftmaxRegressionFunction::SoftmaxRegressionFunction(const arma::mat& data,
                                                      const size_t numClasses,
                                                      const double lambda,
                                                      const bool fitIntercept) :
-    data(data),
-    inputSize(inputSize),
-    numClasses(numClasses),
-    lambda(lambda),
-    fitIntercept(fitIntercept)
+  data(data),
+  inputSize(inputSize),
+  numClasses(numClasses),
+  lambda(lambda),
+  fitIntercept(fitIntercept)
 {
   // Intialize the parameters to suitable values.
   initialPoint = InitializeWeights();
@@ -87,7 +87,7 @@ void SoftmaxRegressionFunction::GetGroundTruthMatrix(const arma::vec& labels,
  * it should consider the parameters.cols(0) intercept term.
  */
 void SoftmaxRegressionFunction::GetProbabilitiesMatrix(
-    const arma::mat& parameters, arma::mat& probabilities) const
+  const arma::mat& parameters, arma::mat& probabilities) const
 {
   arma::mat hypothesis;
 
@@ -100,7 +100,7 @@ void SoftmaxRegressionFunction::GetProbabilitiesMatrix(
     // Since the cost of join maybe high due to the copy of original data,
     // split the hypothesis computation to two components.
     hypothesis = arma::exp(arma::repmat(parameters.col(0), 1, data.n_cols) +
-        parameters.cols(1, parameters.n_cols - 1) * data);
+                           parameters.cols(1, parameters.n_cols - 1) * data);
   }
   else
   {
@@ -139,7 +139,7 @@ double SoftmaxRegressionFunction::Evaluate(const arma::mat& parameters) const
   double logLikelihood, weightDecay, cost;
 
   logLikelihood = arma::accu(groundTruth % arma::log(probabilities)) /
-      data.n_cols;
+                  data.n_cols;
   weightDecay = 0.5 * lambda * arma::accu(parameters % parameters);
 
   // The cost is the sum of the negative log likelihood and the regularization
@@ -172,15 +172,15 @@ void SoftmaxRegressionFunction::Gradient(const arma::mat& parameters,
     // the cost of building matrix [1; data].
     arma::mat inner = probabilities - groundTruth;
     gradient.col(0) =
-        inner * arma::ones<arma::mat>(data.n_cols, 1) / data.n_cols +
-        lambda * parameters.col(0);
+      inner * arma::ones<arma::mat>(data.n_cols, 1) / data.n_cols +
+      lambda * parameters.col(0);
     gradient.cols(1, parameters.n_cols - 1) =
-        inner * data.t() / data.n_cols +
-        lambda * parameters.cols(1, parameters.n_cols - 1);
+      inner * data.t() / data.n_cols +
+      lambda * parameters.cols(1, parameters.n_cols - 1);
   }
   else
   {
     gradient = (probabilities - groundTruth) * data.t() / data.n_cols +
-        lambda * parameters;
+               lambda * parameters;
   }
 }
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
index 3d14627..33ffdfb 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
@@ -80,25 +80,41 @@ class SoftmaxRegressionFunction
   void Gradient(const arma::mat& parameters, arma::mat& gradient) const;
 
   //! Return the initial point for the optimization.
-  const arma::mat& GetInitialPoint() const { return initialPoint; }
+  const arma::mat& GetInitialPoint() const {
+    return initialPoint;
+  }
 
   //! Sets the size of the input vector.
-  size_t& InputSize() { return inputSize; }
+  size_t& InputSize() {
+    return inputSize;
+  }
   //! Gets the size of the input vector.
-  size_t InputSize() const { return inputSize; }
+  size_t InputSize() const {
+    return inputSize;
+  }
 
   //! Sets the number of classes.
-  size_t& NumClasses() { return numClasses; }
+  size_t& NumClasses() {
+    return numClasses;
+  }
   //! Gets the number of classes.
-  size_t NumClasses() const { return numClasses; }
+  size_t NumClasses() const {
+    return numClasses;
+  }
 
   //! Sets the regularization parameter.
-  double& Lambda() { return lambda; }
+  double& Lambda() {
+    return lambda;
+  }
   //! Gets the regularization parameter.
-  double Lambda() const { return lambda; }
+  double Lambda() const {
+    return lambda;
+  }
 
   //! Gets the intercept flag.
-  bool FitIntercept() const { return fitIntercept; }
+  bool FitIntercept() const {
+    return fitIntercept;
+  }
 
  private:
   //! Training data matrix.



More information about the mlpack-git mailing list