greedy_descent.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_OPTIMIZERS_SCD_DESCENT_POLICIES_GREEDY_HPP
13 #define MLPACK_CORE_OPTIMIZERS_SCD_DESCENT_POLICIES_GREEDY_HPP
14 
15 #include <mlpack/core.hpp>
16 
17 namespace mlpack {
18 namespace optimization {
19 
39 {
40  public:
52  template <typename ResolvableFunctionType>
53  static size_t DescentFeature(const size_t /* iteration */,
54  const arma::mat& iterate,
55  const ResolvableFunctionType& function)
56  {
57  size_t bestFeature = 0;
58  double bestDescent = 0;
59  for (size_t i = 0; i < function.NumFeatures(); ++i)
60  {
61  arma::sp_mat fGrad;
62 
63  function.PartialGradient(iterate, i, fGrad);
64 
65  double descent = arma::accu(fGrad);
66  if (descent > bestDescent)
67  {
68  bestFeature = i;
69  bestDescent = descent;
70  }
71  }
72 
73  return bestFeature;
74  }
75 };
76 
77 } // namespace optimization
78 } // namespace mlpack
79 
80 #endif
.hpp
Definition: add_to_po.hpp:21
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
Greedy descent policy for Stochastic Co-ordinate Descent(SCD).
static size_t DescentFeature(const size_t, const arma::mat &iterate, const ResolvableFunctionType &function)
The DescentFeature method is used to get the descent coordinate for the current iteration.