14 #ifndef MLPACK_CORE_OPTIMIZERS_SGDR_SNAPSHOT_ENSEMBLES_HPP 15 #define MLPACK_CORE_OPTIMIZERS_SGDR_SNAPSHOT_ENSEMBLES_HPP 18 namespace optimization {
59 const double multFactor,
60 const double stepSize,
61 const size_t maxIterations,
62 const size_t snapshots) :
63 epochRestart(epochRestart),
64 multFactor(multFactor),
65 constStepSize(stepSize),
66 nextRestart(epochRestart),
71 for (
size_t i = 0, er = epochRestart, nr = nextRestart;
72 i < maxIterations; ++i)
82 snapshotEpochs = epochRestart * std::pow(multFactor,
83 snapshotEpochs - snapshots + 1);
98 if (epoch >= epochRestart)
101 stepSize = 0.5 * constStepSize * (1 + cos((batchRestart / epochBatches)
109 if (epoch > nextRestart)
114 epochRestart *= multFactor;
117 if (epochRestart >= snapshotEpochs)
119 snapshots.push_back(iterate);
123 nextRestart += epochRestart;
140 std::vector<arma::mat>
Snapshots()
const {
return snapshots; }
142 std::vector<arma::mat>&
Snapshots() {
return snapshots; }
152 double constStepSize;
167 size_t snapshotEpochs;
170 std::vector<arma::mat> snapshots;
176 #endif // MLPACK_CORE_OPTIMIZERS_SGDR_CYCLICAL_DECAY_HPP std::vector< arma::mat > & Snapshots()
Modify the snapshots.
Simulate a new warm-started run/restart once a number of epochs are performed.
double & StepSize()
Modify the step size.
std::vector< arma::mat > Snapshots() const
Get the snapshots.
double EpochBatches() const
Get the restart fraction.
double StepSize() const
Get the step size.
SnapshotEnsembles(const size_t epochRestart, const double multFactor, const double stepSize, const size_t maxIterations, const size_t snapshots)
Construct the CyclicalDecay technique a restart method, where the step size decays after each batch a...
double & EpochBatches()
Modify the restart fraction.
void Update(arma::mat &iterate, double &stepSize, const arma::mat &)
This function is called in each iteration after the policy update.