mlpack  git-master
SnapshotSGDR< 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 using the Snapshot ensembles technique. More...

Public Types

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

 

Public Member Functions

 SnapshotSGDR (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 size_t snapshots=5, const bool accumulate=true, const UpdatePolicyType &updatePolicy=UpdatePolicyType())
 Construct the SnapshotSGDR optimizer with snapshot ensembles 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...

 
std::vector< arma::mat > Snapshots () const
 Get the snapshots. More...

 
std::vector< arma::mat > & Snapshots ()
 Modify the snapshots. 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::SnapshotSGDR< 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 using the Snapshot ensembles technique.

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}
}
@inproceedings{Huang2017,
title = {Snapshot ensembles: Train 1, get m for free},
author = {Gao Huang, Yixuan Li, Geoff Pleiss, Zhuang Liu,
John E. Hopcroft, and Kilian Q. Weinberger},
booktitle = {Proceedings of the International Conference on Learning
Representations (ICLR)},
year = {2017},
url = {https://arxiv.org/abs/1704.00109}
}
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 61 of file snapshot_sgdr.hpp.

Member Typedef Documentation

◆ OptimizerType

using OptimizerType = SGD<UpdatePolicyType, SnapshotEnsembles>

Convenience typedef for the internal optimizer construction.

Definition at line 65 of file snapshot_sgdr.hpp.

Constructor & Destructor Documentation

◆ SnapshotSGDR()

SnapshotSGDR ( 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 size_t  snapshots = 5,
const bool  accumulate = true,
const UpdatePolicyType &  updatePolicy = UpdatePolicyType() 
)

Construct the SnapshotSGDR optimizer with snapshot ensembles 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.
snapshotsMaximum number of snapshots.
accumulateAccumulate the snapshot parameter (default true).
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 111 of file snapshot_sgdr.hpp.

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

◆ BatchSize() [2/2]

size_t& BatchSize ( )
inline

Modify the batch size.

Definition at line 113 of file snapshot_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 121 of file snapshot_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 123 of file snapshot_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.

Parameters
functionFunction to optimize.
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 131 of file snapshot_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 133 of file snapshot_sgdr.hpp.

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

◆ Snapshots() [1/2]

std::vector<arma::mat> Snapshots ( ) const
inline

◆ Snapshots() [2/2]

std::vector<arma::mat>& Snapshots ( )
inline

Modify the snapshots.

Definition at line 141 of file snapshot_sgdr.hpp.

References SGD< UpdatePolicyType, DecayPolicyType >::DecayPolicy(), and SnapshotEnsembles::Snapshots().

◆ StepSize() [1/2]

double StepSize ( ) const
inline

Get the step size.

Definition at line 116 of file snapshot_sgdr.hpp.

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

◆ StepSize() [2/2]

double& StepSize ( )
inline

Modify the step size.

Definition at line 118 of file snapshot_sgdr.hpp.

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

◆ Tolerance() [1/2]

double Tolerance ( ) const
inline

Get the tolerance for termination.

Definition at line 126 of file snapshot_sgdr.hpp.

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

◆ Tolerance() [2/2]

double& Tolerance ( )
inline

Modify the tolerance for termination.

Definition at line 128 of file snapshot_sgdr.hpp.

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

◆ UpdatePolicy() [1/2]

const UpdatePolicyType& UpdatePolicy ( ) const
inline

Get the update policy.

Definition at line 147 of file snapshot_sgdr.hpp.

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

◆ UpdatePolicy() [2/2]

UpdatePolicyType& UpdatePolicy ( )
inline

Modify the update policy.

Definition at line 152 of file snapshot_sgdr.hpp.

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


The documentation for this class was generated from the following file: