mlpack  git-master
SVRGType< UpdatePolicyType, DecayPolicyType > Class Template Reference

Stochastic Variance Reduced Gradient is a technique for minimizing a function which can be expressed as a sum of other functions. More...

Public Member Functions

 SVRGType (const double stepSize=0.01, const size_t batchSize=32, const size_t maxIterations=1000, const size_t innerIterations=0, const double tolerance=1e-5, const bool shuffle=true, const UpdatePolicyType &updatePolicy=UpdatePolicyType(), const DecayPolicyType &decayPolicy=DecayPolicyType(), const bool resetPolicy=true)
 Construct the SVRG optimizer with the given function and parameters. More...

 
size_t BatchSize () const
 Get the batch size. More...

 
size_t & BatchSize ()
 Modify the batch size. More...

 
const DecayPolicyType & DecayPolicy () const
 Get the step size decay policy. More...

 
DecayPolicyType & DecayPolicy ()
 Modify the step size decay policy. More...

 
size_t InnerIterations () const
 Get the maximum number of iterations (0 indicates default n / b). More...

 
size_t & InnerIterations ()
 Modify the maximum number of iterations (0 indicates default n / b). 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
DecomposableFunctionType
>
double Optimize (DecomposableFunctionType &function, arma::mat &iterate)
 Optimize the given function using SVRG. More...

 
bool ResetPolicy () const
 Get whether or not the update policy parameters are reset before Optimize call. More...

 
bool & ResetPolicy ()
 Modify whether or not the update policy parameters are reset before Optimize call. More...

 
bool Shuffle () const
 Get whether or not the individual functions are shuffled. More...

 
bool & Shuffle ()
 Modify whether or not the individual functions are shuffled. 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...

 
const UpdatePolicyType & UpdatePolicy () const
 Get the update policy. More...

 
UpdatePolicyType & UpdatePolicy ()
 Modify the update policy. More...

 

Detailed Description


template
<
typename
UpdatePolicyType
=
SVRGUpdate
,
typename
DecayPolicyType
=
NoDecay
>

class mlpack::optimization::SVRGType< UpdatePolicyType, DecayPolicyType >

Stochastic Variance Reduced Gradient is a technique for minimizing a function which can be expressed as a sum of other functions.

That is, suppose we have

\[ f(A) = \sum_{i = 0}^{n} f_i(A) \]

and our task is to minimize $ A $. Stochastic Variance Reduced Gradient iterates over each function $ f_i(A) $, based on the specified update policy. By default vanilla update policy is used. The SVRG class supports either scanning through each of the $ n $ functions $ f_i(A)$ linearly, or in a random sequence. The algorithm continues until $ j$ reaches the maximum number of iterations—or when a full sequence of updates through each of the $ n $ functions $ f_i(A) $ produces an improvement within a certain tolerance $ \epsilon $. That is,

\[ | f(A_{j + n}) - f(A_j) | < \epsilon. \]

The parameter $\epsilon$ is specified by the tolerance parameter to the constructor; $n$ is specified by the maxIterations parameter.

This class is useful for data-dependent functions whose objective function can be expressed as a sum of objective functions operating on an individual point. Then, SVRG considers the gradient of the objective function operating on an individual point in its update of $ A $.

For SVRG to work, a DecomposableFunctionType template parameter is required. This class must implement the following function:

size_t NumFunctions(); double Evaluate(const arma::mat& coordinates, const size_t i, const size_t batchSize); void Gradient(const arma::mat& coordinates, const size_t i, arma::mat& gradient, const size_t batchSize);

NumFunctions() should return the number of functions ( $n$), and in the other two functions, the parameter i refers to which individual function (or gradient) is being evaluated. So, for the case of a data-dependent function, such as NCA (see mlpack::nca::NCA), NumFunctions() should return the number of points in the dataset, and Evaluate(coordinates, 0) will evaluate the objective function on the first point in the dataset (presumably, the dataset is held internally in the DecomposableFunctionType).

For more information, please refer to:

@inproceedings{Johnson2013,
author = {Johnson, Rie and Zhang, Tong},
title = {Accelerating Stochastic Gradient Descent Using Predictive
Variance Reduction},
booktitle = {Proceedings of the 26th International Conference on Neural
Information Processing Systems - Volume 1},
series = {NIPS'13},
year = {2013},
location = {Lake Tahoe, Nevada},
pages = {315--323},
numpages = {9},
publisher = {Curran Associates Inc.},
}
Template Parameters
UpdatePolicyTypeupdate policy used by SVRG during the iterative update process. By default vanilla update policy (see mlpack::optimization::VanillaUpdate) is used.
DecayPolicyTypeDecay policy used during the iterative update process to adjust the step size. By default the step size isn't going to be adjusted (i.e. NoDecay is used).

Definition at line 101 of file svrg.hpp.

Constructor & Destructor Documentation

◆ SVRGType()

SVRGType ( const double  stepSize = 0.01,
const size_t  batchSize = 32,
const size_t  maxIterations = 1000,
const size_t  innerIterations = 0,
const double  tolerance = 1e-5,
const bool  shuffle = true,
const UpdatePolicyType &  updatePolicy = UpdatePolicyType(),
const DecayPolicyType &  decayPolicy = DecayPolicyType(),
const bool  resetPolicy = true 
)

Construct the SVRG 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. The maximum number of iterations refers to the maximum number of points that are processed (i.e., one iteration equals one point; one iteration does not equal one pass over the dataset).

Parameters
stepSizeStep size for each iteration.
batchSizeBatch size to use for each step.
maxIterationsMaximum number of iterations allowed (0 means no limit).
innerIterationsThe number of inner iterations allowed (0 means n / batchSize). Note that the full gradient is only calculated in the outer iteration.
toleranceMaximum absolute tolerance to terminate algorithm.
shuffleIf true, the function order is shuffled; otherwise, each function is visited in linear order.
updatePolicyInstantiated update policy used to adjust the given parameters.
decayPolicyInstantiated decay policy used to adjust the step size.
resetPolicyFlag that determines whether update policy parameters are reset before every Optimize call.

Member Function Documentation

◆ BatchSize() [1/2]

size_t BatchSize ( ) const
inline

Get the batch size.

Definition at line 157 of file svrg.hpp.

◆ BatchSize() [2/2]

size_t& BatchSize ( )
inline

Modify the batch size.

Definition at line 159 of file svrg.hpp.

◆ DecayPolicy() [1/2]

const DecayPolicyType& DecayPolicy ( ) const
inline

Get the step size decay policy.

Definition at line 194 of file svrg.hpp.

◆ DecayPolicy() [2/2]

DecayPolicyType& DecayPolicy ( )
inline

Modify the step size decay policy.

Definition at line 196 of file svrg.hpp.

◆ InnerIterations() [1/2]

size_t InnerIterations ( ) const
inline

Get the maximum number of iterations (0 indicates default n / b).

Definition at line 167 of file svrg.hpp.

◆ InnerIterations() [2/2]

size_t& InnerIterations ( )
inline

Modify the maximum number of iterations (0 indicates default n / b).

Definition at line 169 of file svrg.hpp.

◆ MaxIterations() [1/2]

size_t MaxIterations ( ) const
inline

Get the maximum number of iterations (0 indicates no limit).

Definition at line 162 of file svrg.hpp.

◆ MaxIterations() [2/2]

size_t& MaxIterations ( )
inline

Modify the maximum number of iterations (0 indicates no limit).

Definition at line 164 of file svrg.hpp.

◆ Optimize()

double Optimize ( DecomposableFunctionType &  function,
arma::mat &  iterate 
)

Optimize the given function using SVRG.

The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.

Template Parameters
DecomposableFunctionTypeType of the function to be optimized.
Parameters
functionFunction to optimize.
iterateStarting point (will be modified).
Returns
Objective value of the final point.

◆ ResetPolicy() [1/2]

bool ResetPolicy ( ) const
inline

Get whether or not the update policy parameters are reset before Optimize call.

Definition at line 183 of file svrg.hpp.

◆ ResetPolicy() [2/2]

bool& ResetPolicy ( )
inline

Modify whether or not the update policy parameters are reset before Optimize call.

Definition at line 186 of file svrg.hpp.

◆ Shuffle() [1/2]

bool Shuffle ( ) const
inline

Get whether or not the individual functions are shuffled.

Definition at line 177 of file svrg.hpp.

◆ Shuffle() [2/2]

bool& Shuffle ( )
inline

Modify whether or not the individual functions are shuffled.

Definition at line 179 of file svrg.hpp.

◆ StepSize() [1/2]

double StepSize ( ) const
inline

Get the step size.

Definition at line 152 of file svrg.hpp.

◆ StepSize() [2/2]

double& StepSize ( )
inline

Modify the step size.

Definition at line 154 of file svrg.hpp.

◆ Tolerance() [1/2]

double Tolerance ( ) const
inline

Get the tolerance for termination.

Definition at line 172 of file svrg.hpp.

◆ Tolerance() [2/2]

double& Tolerance ( )
inline

Modify the tolerance for termination.

Definition at line 174 of file svrg.hpp.

◆ UpdatePolicy() [1/2]

const UpdatePolicyType& UpdatePolicy ( ) const
inline

Get the update policy.

Definition at line 189 of file svrg.hpp.

◆ UpdatePolicy() [2/2]

UpdatePolicyType& UpdatePolicy ( )
inline

Modify the update policy.

Definition at line 191 of file svrg.hpp.


The documentation for this class was generated from the following file:
  • /var/www/www.mlpack.org/mlpack-git/src/mlpack/core/optimizers/svrg/svrg.hpp