[mlpack-git] master: Change API slightly to match other code. Realistically, this probably needs further thought: C++11 gives us rvalue references, so we can do something a bit smarter to validate parameters without any unnecessary copies that would result from Mutator(const T&) (or whatever). (d0a965e)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 11:23:51 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/c872c173626a9457fc4e2387c37b0b3bd324185f...2fbecc5f7ea46c312d4bbf15be3c8bf7dbd53005
>---------------------------------------------------------------
commit d0a965ed9876a6edd32c91ceebb1e0d0bc12b513
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Mar 5 11:07:10 2015 -0500
Change API slightly to match other code.
Realistically, this probably needs further thought: C++11 gives us rvalue references, so we can do something a bit smarter to validate parameters without any unnecessary copies that would result from Mutator(const T&) (or whatever).
>---------------------------------------------------------------
d0a965ed9876a6edd32c91ceebb1e0d0bc12b513
.../softmax_regression/softmax_regression.hpp | 42 +++++-----------------
.../softmax_regression_function.hpp | 39 ++++----------------
2 files changed, 16 insertions(+), 65 deletions(-)
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression.hpp b/src/mlpack/methods/softmax_regression/softmax_regression.hpp
index bf5e6c7..1f95c81 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression.hpp
@@ -114,46 +114,22 @@ class SoftmaxRegression
double ComputeAccuracy(const arma::mat& testData, const arma::vec& labels);
//! Sets the size of the input vector.
- void InputSize(const size_t input)
- {
- this->inputSize = input;
- }
-
+ 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.
- void NumClasses(const size_t classes)
- {
- this->numClasses = classes;
- }
-
+ 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.
- void Lambda(const double l)
- {
- this->lambda = l;
- }
-
+ double& Lambda() { return lambda; }
//! Gets the regularization parameter.
- double Lambda() const
- {
- return lambda;
- }
-
- //! Gets the intercept term flag.
- bool FitIntercept() const
- {
- return fitIntercept;
- }
+ double Lambda() const { return lambda; }
+
+ //! Gets the intercept term flag. We can't change this after training.
+ bool FitIntercept() const { return fitIntercept; }
private:
//! Parameters after optimization.
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
index bd09041..3d14627 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp
@@ -83,46 +83,22 @@ class SoftmaxRegressionFunction
const arma::mat& GetInitialPoint() const { return initialPoint; }
//! Sets the size of the input vector.
- void InputSize(const size_t input)
- {
- this->inputSize = input;
- }
-
+ 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.
- void NumClasses(const size_t classes)
- {
- this->numClasses = classes;
- }
-
+ 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.
- void Lambda(const double l)
- {
- this->lambda = l;
- }
-
+ 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.
@@ -139,7 +115,6 @@ class SoftmaxRegressionFunction
double lambda;
//! Intercept term flag.
bool fitIntercept;
-
};
}; // namespace regression
More information about the mlpack-git
mailing list