Gradient Descent is a technique to minimize a function. More...
Public Member Functions | |
| GradientDescent (const double stepSize=0.01, const size_t maxIterations=100000, const double tolerance=1e-5) | |
| Construct the Gradient Descent optimizer with the given function and parameters. More... | |
| size_t | MaxIterations () const |
| Get the maximum number of iterations (0 indicates no limit). More... | |
| size_t & | MaxIterations () |
| Modify the maximum number of iterations (0 indicates no limit). More... | |
template < typename FunctionType > | |
| double | Optimize (FunctionType &function, arma::mat &iterate) |
| Optimize the given function using gradient descent. More... | |
template < typename FunctionType > | |
| double | Optimize (FunctionType &function, arma::mat &iterate, data::DatasetMapper< data::IncrementPolicy, double > &datasetInfo) |
| Assert all dimensions are numeric and optimize the given function using gradient descent. More... | |
| double | StepSize () const |
| Get the step size. More... | |
| double & | StepSize () |
| Modify the step size. More... | |
| double | Tolerance () const |
| Get the tolerance for termination. More... | |
| double & | Tolerance () |
| Modify the tolerance for termination. More... | |
Gradient Descent is a technique to minimize a function.
To find a local minimum of a function using gradient descent, one takes steps proportional to the negative of the gradient of the function at the current point, producing the following update scheme:
where
is a parameter which specifies the step size.
is the function being optimized. The algorithm continues until
reaches the maximum number of iterations—or when an update produces an improvement within a certain tolerance
. That is,
The parameter
is specified by the tolerance parameter to the constructor.
For Gradient Descent to work, a FunctionType template parameter is required. This class must implement the following function:
double Evaluate(const arma::mat& coordinates); void Gradient(const arma::mat& coordinates, arma::mat& gradient);
Definition at line 49 of file gradient_descent.hpp.
| GradientDescent | ( | const double | stepSize = 0.01, |
| const size_t | maxIterations = 100000, |
||
| const double | tolerance = 1e-5 |
||
| ) |
Construct the Gradient Descent optimizer with the given function and parameters.
The defaults here are not necessarily good for the given problem, so it is suggested that the values used be tailored to the task at hand.
| function | Function to be optimized (minimized). |
| stepSize | Step size for each iteration. |
| maxIterations | Maximum number of iterations allowed (0 means no limit). |
| tolerance | Maximum absolute tolerance to terminate algorithm. |
|
inline |
Get the maximum number of iterations (0 indicates no limit).
Definition at line 108 of file gradient_descent.hpp.
|
inline |
Modify the maximum number of iterations (0 indicates no limit).
Definition at line 110 of file gradient_descent.hpp.
| double Optimize | ( | FunctionType & | function, |
| arma::mat & | iterate | ||
| ) |
Optimize the given function using gradient descent.
The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.
| FunctionType | Type of the function to optimize. |
| function | Function to optimize. |
| iterate | Starting point (will be modified). |
| double Optimize | ( | FunctionType & | function, |
| arma::mat & | iterate, | ||
| data::DatasetMapper< data::IncrementPolicy, double > & | datasetInfo | ||
| ) |
Assert all dimensions are numeric and optimize the given function using gradient descent.
The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.
This overload is intended to be used primarily by the hyper-parameter tuning module.
| FunctionType | Type of the function to optimize. |
| function | Function to optimize. |
| iterate | Starting point (will be modified). |
| datasetInfo | Type information for each dimension of the dataset. |
|
inline |
Get the step size.
Definition at line 103 of file gradient_descent.hpp.
|
inline |
Modify the step size.
Definition at line 105 of file gradient_descent.hpp.
|
inline |
Get the tolerance for termination.
Definition at line 113 of file gradient_descent.hpp.
|
inline |
Modify the tolerance for termination.
Definition at line 115 of file gradient_descent.hpp.