mlpack  git-master
SGDR< UpdatePolicyType > Class Template Reference

This class is based on Mini-batch Stochastic Gradient Descent class and simulates a new warm-started run/restart once a number of epochs are performed. More...

Public Types

using OptimizerType = SGD< UpdatePolicyType, CyclicalDecay >
 Convenience typedef for the internal optimizer construction. More...

 

Public Member Functions

 SGDR (const size_t epochRestart=50, const double multFactor=2.0, const size_t batchSize=1000, const double stepSize=0.01, const size_t maxIterations=100000, const double tolerance=1e-5, const bool shuffle=true, const UpdatePolicyType &updatePolicy=UpdatePolicyType())
 Construct the SGDR 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...

 
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 SGDR. 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
=
MomentumUpdate
>

class mlpack::optimization::SGDR< UpdatePolicyType >

This class is based on Mini-batch Stochastic Gradient Descent class and simulates a new warm-started run/restart once a number of epochs are performed.

For more information, please refer to:

@article{Loshchilov2016,
title = {{SGDR:} Stochastic Gradient Descent with Restarts},
author = {Ilya Loshchilov and Frank Hutter},
journal = {CoRR},
year = {2016},
url = {https://arxiv.org/abs/1608.03983}
}
Template Parameters
UpdatePolicyTypeUpdate policy used during the iterative update process. By default the momentum update policy (see mlpack::optimization::MomentumUpdate) is used.

Definition at line 48 of file sgdr.hpp.

Member Typedef Documentation

◆ OptimizerType

using OptimizerType = SGD<UpdatePolicyType, CyclicalDecay>

Convenience typedef for the internal optimizer construction.

Definition at line 52 of file sgdr.hpp.

Constructor & Destructor Documentation

◆ SGDR()

SGDR ( const size_t  epochRestart = 50,
const double  multFactor = 2.0,
const size_t  batchSize = 1000,
const double  stepSize = 0.01,
const size_t  maxIterations = 100000,
const double  tolerance = 1e-5,
const bool  shuffle = true,
const UpdatePolicyType &  updatePolicy = UpdatePolicyType() 
)

Construct the SGDR 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 for the task at hand. The maximum number of iterations refers to the maximum number of mini-batches that are processed.

Parameters
epochRestartInitial epoch where decay is applied.
batchSizeSize of each mini-batch.
stepSizeStep size for each iteration.
maxIterationsMaximum number of iterations allowed (0 means no limit).
toleranceMaximum absolute tolerance to terminate algorithm.
shuffleIf true, the mini-batch order is shuffled; otherwise, each mini-batch is visited in linear order.
updatePolicyInstantiated update policy used to adjust the given parameters.

Member Function Documentation

◆ BatchSize() [1/2]

size_t BatchSize ( ) const
inline

Get the batch size.

Definition at line 95 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::BatchSize().

◆ BatchSize() [2/2]

size_t& BatchSize ( )
inline

Modify the batch size.

Definition at line 97 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::BatchSize().

◆ MaxIterations() [1/2]

size_t MaxIterations ( ) const
inline

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

Definition at line 105 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::MaxIterations().

◆ MaxIterations() [2/2]

size_t& MaxIterations ( )
inline

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

Definition at line 107 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::MaxIterations().

◆ Optimize()

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

Optimize the given function using SGDR.

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 be optimized.
iterateStarting point (will be modified).
Returns
Objective value of the final point.

◆ Shuffle() [1/2]

bool Shuffle ( ) const
inline

Get whether or not the individual functions are shuffled.

Definition at line 115 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::Shuffle().

◆ Shuffle() [2/2]

bool& Shuffle ( )
inline

Modify whether or not the individual functions are shuffled.

Definition at line 117 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::Shuffle().

◆ StepSize() [1/2]

double StepSize ( ) const
inline

Get the step size.

Definition at line 100 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::StepSize().

◆ StepSize() [2/2]

double& StepSize ( )
inline

Modify the step size.

Definition at line 102 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::StepSize().

◆ Tolerance() [1/2]

double Tolerance ( ) const
inline

Get the tolerance for termination.

Definition at line 110 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::Tolerance().

◆ Tolerance() [2/2]

double& Tolerance ( )
inline

Modify the tolerance for termination.

Definition at line 112 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::Tolerance().

◆ UpdatePolicy() [1/2]

const UpdatePolicyType& UpdatePolicy ( ) const
inline

Get the update policy.

Definition at line 120 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::UpdatePolicy().

◆ UpdatePolicy() [2/2]

UpdatePolicyType& UpdatePolicy ( )
inline

Modify the update policy.

Definition at line 125 of file sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::UpdatePolicy().


The documentation for this class was generated from the following file:
  • src/mlpack/core/optimizers/sgdr/sgdr.hpp