mlpack  git-master
bigbatch_sgd.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_OPTIMIZERS_BIGBATCH_SGD_BIGBATCH_SGD_HPP
15 #define MLPACK_CORE_OPTIMIZERS_BIGBATCH_SGD_BIGBATCH_SGD_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 #include "adaptive_stepsize.hpp"
21 
22 namespace mlpack {
23 namespace optimization {
24 
92 template<typename UpdatePolicyType = AdaptiveStepsize>
94 {
95  public:
112  BigBatchSGD(const size_t batchSize = 1000,
113  const double stepSize = 0.01,
114  const double batchDelta = 0.1,
115  const size_t maxIterations = 100000,
116  const double tolerance = 1e-5,
117  const bool shuffle = true);
128  template<typename DecomposableFunctionType>
129  double Optimize(DecomposableFunctionType& function,
130  arma::mat& iterate);
131 
133  size_t BatchSize() const { return batchSize; }
135  size_t& BatchSize() { return batchSize; }
136 
138  double StepSize() const { return stepSize; }
140  double& StepSize() { return stepSize; }
141 
143  double BatchDelta() const { return batchDelta; }
145  double& BatchDelta() { return batchDelta; }
146 
148  size_t MaxIterations() const { return maxIterations; }
150  size_t& MaxIterations() { return maxIterations; }
151 
153  double Tolerance() const { return tolerance; }
155  double& Tolerance() { return tolerance; }
156 
158  bool Shuffle() const { return shuffle; }
160  bool& Shuffle() { return shuffle; }
161 
163  UpdatePolicyType UpdatePolicy() const { return updatePolicy; }
165  UpdatePolicyType& UpdatePolicy() { return updatePolicy; }
166 
167  private:
169  size_t batchSize;
170 
172  double stepSize;
173 
175  double batchDelta;
176 
178  size_t maxIterations;
179 
181  double tolerance;
182 
185  bool shuffle;
186 
188  UpdatePolicyType updatePolicy;
189 };
190 
193 
194 } // namespace optimization
195 } // namespace mlpack
196 
197 // Include implementation.
198 #include "bigbatch_sgd_impl.hpp"
199 
200 #endif
.hpp
Definition: add_to_po.hpp:21
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
The core includes that mlpack expects; standard C++ includes and Armadillo.
double BatchDelta() const
Get the batch delta.
size_t BatchSize() const
Get the batch size.
UpdatePolicyType UpdatePolicy() const
Get the update policy.
BigBatchSGD(const size_t batchSize=1000, const double stepSize=0.01, const double batchDelta=0.1, const size_t maxIterations=100000, const double tolerance=1e-5, const bool shuffle=true)
Construct the BigBatchSGD optimizer with the given function and parameters.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
double StepSize() const
Get the step size.
double & StepSize()
Modify the step size.
UpdatePolicyType & UpdatePolicy()
Modify the update policy.
double Optimize(DecomposableFunctionType &function, arma::mat &iterate)
Optimize the given function using big-batch SGD.
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
Big-batch Stochastic Gradient Descent is a technique for minimizing a function which can be expressed...
double Tolerance() const
Get the tolerance for termination.
bool Shuffle() const
Get whether or not the individual functions are shuffled.
double & BatchDelta()
Modify the batch delta.
size_t & BatchSize()
Modify the batch size.
double & Tolerance()
Modify the tolerance for termination.