|
GClasses
|
Optimizes the parameters of a differentiable function using an objective function.
#include <GOptimizer.h>
Public Member Functions | |
| GNeuralNetOptimizer (GNeuralNet &model, GRand &rand, GObjective *objective=NULL) | |
| virtual | ~GNeuralNetOptimizer () |
| size_t | batchesPerEpoch () const |
| size_t | batchSize () const |
| virtual void | computeGradient (const GVec &feat, const GVec &lab)=0 |
| Evaluate feat and lab, and update the model's gradient. More... | |
| GContextNeuralNet & | context () |
| Returns the default context for training the model. (Note: It is allocated lazily. This should not be called before layers are added to the model. For multi-threaded optimization, a separate context should be allocated for each thread.) More... | |
| virtual void | descendGradient (double learningRate)=0 |
| Step the model's parameters in the direction of the calculated gradient scaled by learningRate. More... | |
| size_t | epochs () const |
| double | improvementThresh () const |
| double | learningRate () const |
| GNeuralNet & | model () |
| GObjective * | objective () |
| void | optimize (const GMatrix &features, const GMatrix &labels) |
| virtual void | optimizeBatch (const GMatrix &features, const GMatrix &labels, size_t start, size_t batchSize) |
| Update and apply the gradient for a single batch in order. More... | |
| void | optimizeBatch (const GMatrix &features, const GMatrix &labels, size_t start) |
| virtual void | optimizeBatch (const GMatrix &features, const GMatrix &labels, GRandomIndexIterator &ii, size_t batchSize) |
| Update and apply the gradient for a single batch in randomized order. More... | |
| void | optimizeBatch (const GMatrix &features, const GMatrix &labels, GRandomIndexIterator &ii) |
| virtual void | optimizeIncremental (const GVec &feat, const GVec &lab) |
| Update and apply the gradient for a single training sample (on-line). More... | |
| void | optimizeWithValidation (const GMatrix &features, const GMatrix &labels, const GMatrix &validationFeat, const GMatrix &validationLab) |
| void | optimizeWithValidation (const GMatrix &features, const GMatrix &labels, double validationPortion=0.35) |
| virtual void | prepareForOptimizing ()=0 |
| Prepare for optimization (i.e. allocate delta vectors). More... | |
| GRand & | rand () |
| void | resetState () |
| Flushes the memory in any recurrent units in the network. This method should be called when beginning a new training sequence with neural networks that contain any recurrent blocks. More... | |
| void | setBatchesPerEpoch (size_t b) |
| void | setBatchSize (size_t b) |
| void | setEpochs (size_t e) |
| void | setImprovementThresh (double m) |
| void | setLearningRate (double l) |
| void | setObjective (GObjective *objective) |
| void | setWindowSize (size_t w) |
| double | sumLoss (const GMatrix &features, const GMatrix &labels) |
| size_t | windowSize () const |
Protected Attributes | |
| size_t | m_batchesPerEpoch |
| size_t | m_batchSize |
| size_t | m_epochs |
| double | m_learningRate |
| double | m_minImprovement |
| GNeuralNet & | m_model |
| GObjective * | m_objective |
| GContextNeuralNet * | m_pContext |
| GRand & | m_rand |
| size_t | m_windowSize |
| GClasses::GNeuralNetOptimizer::GNeuralNetOptimizer | ( | GNeuralNet & | model, |
| GRand & | rand, | ||
| GObjective * | objective = NULL |
||
| ) |
|
virtual |
|
inline |
|
inline |
|
pure virtual |
Evaluate feat and lab, and update the model's gradient.
Implemented in GClasses::GRMSPropOptimizer, GClasses::GAdamOptimizer, and GClasses::GSGDOptimizer.
| GContextNeuralNet& GClasses::GNeuralNetOptimizer::context | ( | ) |
Returns the default context for training the model. (Note: It is allocated lazily. This should not be called before layers are added to the model. For multi-threaded optimization, a separate context should be allocated for each thread.)
|
pure virtual |
Step the model's parameters in the direction of the calculated gradient scaled by learningRate.
Implemented in GClasses::GRMSPropOptimizer, GClasses::GAdamOptimizer, and GClasses::GSGDOptimizer.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Update and apply the gradient for a single batch in order.
| void GClasses::GNeuralNetOptimizer::optimizeBatch | ( | const GMatrix & | features, |
| const GMatrix & | labels, | ||
| size_t | start | ||
| ) |
|
virtual |
Update and apply the gradient for a single batch in randomized order.
| void GClasses::GNeuralNetOptimizer::optimizeBatch | ( | const GMatrix & | features, |
| const GMatrix & | labels, | ||
| GRandomIndexIterator & | ii | ||
| ) |
|
virtual |
Update and apply the gradient for a single training sample (on-line).
| void GClasses::GNeuralNetOptimizer::optimizeWithValidation | ( | const GMatrix & | features, |
| const GMatrix & | labels, | ||
| const GMatrix & | validationFeat, | ||
| const GMatrix & | validationLab | ||
| ) |
| void GClasses::GNeuralNetOptimizer::optimizeWithValidation | ( | const GMatrix & | features, |
| const GMatrix & | labels, | ||
| double | validationPortion = 0.35 |
||
| ) |
|
pure virtual |
Prepare for optimization (i.e. allocate delta vectors).
Implemented in GClasses::GRMSPropOptimizer, GClasses::GAdamOptimizer, and GClasses::GSGDOptimizer.
|
inline |
| void GClasses::GNeuralNetOptimizer::resetState | ( | ) |
Flushes the memory in any recurrent units in the network. This method should be called when beginning a new training sequence with neural networks that contain any recurrent blocks.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |