From 6ff9b468f7febd0bbaf0ce4e7559b5afc6b976e9 Mon Sep 17 00:00:00 2001 From: Shikhar Bhardwaj Date: Wed, 23 Aug 2017 18:03:51 +0530 Subject: [PATCH] Update documentation to rename FeatureGradient -> PartialGradient --- doc/policies/functiontype.hpp | 2 +- .../optimizers/parallel_sgd/sparse_test_function.hpp | 2 +- .../scd/descent_policies/greedy_descent.hpp | 2 +- src/mlpack/core/optimizers/scd/scd.hpp | 4 ++-- src/mlpack/core/optimizers/scd/scd_impl.hpp | 2 +- .../logistic_regression_function.hpp | 2 +- .../logistic_regression_function_impl.hpp | 2 +- .../softmax_regression_function.cpp | 2 +- .../softmax_regression_function.hpp | 2 +- src/mlpack/tests/scd_test.cpp | 12 ++++++------ 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/policies/functiontype.hpp b/doc/policies/functiontype.hpp index 581f1e4bdb..1540a98a14 100644 --- a/doc/policies/functiontype.hpp +++ b/doc/policies/functiontype.hpp @@ -11,7 +11,7 @@ algorithm. The \c FunctionType template parameter required by the Optimizer class can have additional requirements imposed on it, depending on the type of optimizer used. -@section Interface requirements +@section requirements Interface requirements The most basic requirements for the \c FunctionType parameter are the implementations of two public member functions, with the following interface diff --git a/src/mlpack/core/optimizers/parallel_sgd/sparse_test_function.hpp b/src/mlpack/core/optimizers/parallel_sgd/sparse_test_function.hpp index 13bc58984d..426a0ef973 100644 --- a/src/mlpack/core/optimizers/parallel_sgd/sparse_test_function.hpp +++ b/src/mlpack/core/optimizers/parallel_sgd/sparse_test_function.hpp @@ -72,7 +72,7 @@ class SparseTestFunction } //! Evaluate the gradient of a feature function. - void FeatureGradient(const arma::mat& coordinates, + void PartialGradient(const arma::mat& coordinates, const size_t j, arma::sp_mat& gradient) const { diff --git a/src/mlpack/core/optimizers/scd/descent_policies/greedy_descent.hpp b/src/mlpack/core/optimizers/scd/descent_policies/greedy_descent.hpp index f0b3a9c194..f46f9378a2 100644 --- a/src/mlpack/core/optimizers/scd/descent_policies/greedy_descent.hpp +++ b/src/mlpack/core/optimizers/scd/descent_policies/greedy_descent.hpp @@ -58,7 +58,7 @@ class GreedyDescent { arma::sp_mat fGrad; - function.FeatureGradient(iterate, i, fGrad); + function.PartialGradient(iterate, i, fGrad); double descent = arma::accu(fGrad); if (descent > bestDescent) diff --git a/src/mlpack/core/optimizers/scd/scd.hpp b/src/mlpack/core/optimizers/scd/scd.hpp index be6434f020..e04c102e9c 100644 --- a/src/mlpack/core/optimizers/scd/scd.hpp +++ b/src/mlpack/core/optimizers/scd/scd.hpp @@ -34,13 +34,13 @@ namespace optimization { * * size_t NumFeatures(); * double Evaluate(const arma::mat& coordinates); - * void FeatureGradient(const arma::mat& coordinates, + * void PartialGradient(const arma::mat& coordinates, * const size_t j, * arma::sp_mat& gradient); * * NumFeatures() should return the number of features in the decision variable. * Evaluate gives the value of the loss function at the current decision - * variable and FeatureGradient is used to evaluate the partial gradient with + * variable and PartialGradient is used to evaluate the partial gradient with * respect to the jth feature. * * @tparam ResolvableFunctionType A function whose partial gradients with diff --git a/src/mlpack/core/optimizers/scd/scd_impl.hpp b/src/mlpack/core/optimizers/scd/scd_impl.hpp index 7101e7cc79..8fbc00fe06 100644 --- a/src/mlpack/core/optimizers/scd/scd_impl.hpp +++ b/src/mlpack/core/optimizers/scd/scd_impl.hpp @@ -50,7 +50,7 @@ double SCD::Optimize(ResolvableFunctionType& function, size_t featureIdx = descentPolicy.DescentFeature(i, iterate, function); // Get the partial gradient with respect to this feature. - function.FeatureGradient(iterate, featureIdx, gradient); + function.PartialGradient(iterate, featureIdx, gradient); // Update the decision variable with the partial gradient. iterate.col(featureIdx) -= stepSize * gradient.col(featureIdx); diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index 6386192180..fffcde1430 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -118,7 +118,7 @@ class LogisticRegressionFunction * be computed. * @param gradient Sparse matrix to output gradient into. */ - void FeatureGradient(const arma::mat& parameters, + void PartialGradient(const arma::mat& parameters, const size_t j, arma::sp_mat& gradient) const; diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp index 4a5dd91fc3..dae33fa50d 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp @@ -177,7 +177,7 @@ void LogisticRegressionFunction::Gradient( * function with respect to the individual features in the parameter. */ template -void LogisticRegressionFunction::FeatureGradient( +void LogisticRegressionFunction::PartialGradient( const arma::mat& parameters, const size_t j, arma::sp_mat& gradient) const diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp index d8162861b5..3de7611a18 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.cpp @@ -206,7 +206,7 @@ void SoftmaxRegressionFunction::Gradient(const arma::mat& parameters, } } -void SoftmaxRegressionFunction::FeatureGradient(const arma::mat& parameters, +void SoftmaxRegressionFunction::PartialGradient(const arma::mat& parameters, const size_t j, arma::sp_mat& gradient) const { diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp index 194192ccbb..e7d15689e0 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp @@ -120,7 +120,7 @@ class SoftmaxRegressionFunction * gradient is to be computed. * @param gradient Out param for the gradient value. */ - void FeatureGradient(const arma::mat& parameters, + void PartialGradient(const arma::mat& parameters, size_t j, arma::sp_mat& gradient) const; diff --git a/src/mlpack/tests/scd_test.cpp b/src/mlpack/tests/scd_test.cpp index 34009436b5..2d5411ff1d 100644 --- a/src/mlpack/tests/scd_test.cpp +++ b/src/mlpack/tests/scd_test.cpp @@ -96,9 +96,9 @@ BOOST_AUTO_TEST_CASE(GreedyDescentTest) } /** - * Test that LogisticRegressionFunction::FeatureGradient() works as expected. + * Test that LogisticRegressionFunction::PartialGradient() works as expected. */ -BOOST_AUTO_TEST_CASE(LogisticRegressionFunctionFeatureGradientTest) +BOOST_AUTO_TEST_CASE(LogisticRegressionFunctionPartialGradientTest) { // Evaluate the gradient and feature gradient and equate. arma::mat predictors("0 0 0.4; 0 0 0.6; 0 0.3 0; 0.2 0 0; 0.2 -0.5 0;"); @@ -115,16 +115,16 @@ BOOST_AUTO_TEST_CASE(LogisticRegressionFunctionFeatureGradientTest) for (size_t i = 0; i < f.NumFeatures(); ++i) { arma::sp_mat fGrad; - f.FeatureGradient(testPoint, i, fGrad); + f.PartialGradient(testPoint, i, fGrad); CheckMatrices(testGradient.col(i), arma::mat(fGrad.col(i))); } } /** - * Test that SoftmaxRegressionFunction::FeatureGradient() works as expected. + * Test that SoftmaxRegressionFunction::PartialGradient() works as expected. */ -BOOST_AUTO_TEST_CASE(SoftmaxRegressionFunctionFeatureGradientTest) +BOOST_AUTO_TEST_CASE(SoftmaxRegressionFunctionPartialGradientTest) { const size_t points = 1000; const size_t inputSize = 10; @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(SoftmaxRegressionFunctionFeatureGradientTest) // Get the gradient for this feature. arma::sp_mat fGrad; - srf.FeatureGradient(parameters, j, fGrad); + srf.PartialGradient(parameters, j, fGrad); CheckMatrices(gradient.col(j), arma::mat(fGrad.col(j))); }