NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

FgNadamSolver.h
1
11#pragma once
12
13#include <MachineLearning/BaseGradientOptimizationMethod.h>
14
15 namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
79 template<typename Scalar, LineSearchType LSType = MoreThuente>
80 class NE_IMPEXP NadamSolver : public BaseGradientOptimizationMethod<Scalar, LSType>
81 {
82 public:
83
93 NadamSolver(int numberOfVariables);
94
106 NadamSolver(int numberOfVariables,
107 std::function<Scalar(const af::array&, af::array&)> function);
108
116 NadamSolver(NonlinearObjectiveFunction<Scalar>* function);
117
123 ~NadamSolver();
124
132 void SetBeta1(Scalar beta1);
133
141 void SetBeta2(Scalar beta2);
142
150 void SetAlpha(Scalar alpha);
151
159 void SetEpsilon(Scalar epsilon);
160
168 void SetDecay(Scalar decay);
169
177 Scalar GetBeta1();
178
186 Scalar GetBeta2();
187
195 Scalar GetAlpha();
196
204 Scalar GetEpsilon();
205
213 Scalar GetDecay();
214
215 protected:
216
227 virtual bool Optimize(int* cycle = nullptr) override;
228
229 private:
230 Scalar min_step; // The minimum step length allowed in the line search.
231 Scalar max_step; // The maximum step length allowed in the line search.
232
233 Scalar sAlpha; // learning rate
234 Scalar sBeta1; // exponential decay rate for the first moment estimates (e.g. 0.9)
235 Scalar sBeta2; // exponential decay rate for the second-moment estimates (e.g. 0.999).
236 Scalar sEpsilon; // small number to prevent any division by zero in the implementation
237 Scalar sDecay;
238 Scalar delta;
239 Scalar sCumBeta1;
240 };
241 }
242}
243
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod
Base class for gradient-based optimization methods.
Definition: BaseGradientOptimizationMethod.h:40
NeuralEngine::MachineLearning::NadamSolver
AdaMax optimizer.
Definition: FgNadamSolver.h:81
NeuralEngine::MachineLearning::NadamSolver::GetBeta1
Scalar GetBeta1()
Gets decay rate for the first moment estimates.
NeuralEngine::MachineLearning::NadamSolver::NadamSolver
NadamSolver(NonlinearObjectiveFunction< Scalar > *function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::NadamSolver::SetBeta2
void SetBeta2(Scalar beta2)
Sets decay rate for the second-moment estimates.
NeuralEngine::MachineLearning::NadamSolver::GetAlpha
Scalar GetAlpha()
Gets the learning rate.
NeuralEngine::MachineLearning::NadamSolver::Optimize
virtual bool Optimize(int *cycle=nullptr) override
Implements the actual optimization algorithm. This method should try to minimize the objective functi...
NeuralEngine::MachineLearning::NadamSolver::SetBeta1
void SetBeta1(Scalar beta1)
Sets decay rate for the first moment estimates.
NeuralEngine::MachineLearning::NadamSolver::NadamSolver
NadamSolver(int numberOfVariables)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::NadamSolver::SetEpsilon
void SetEpsilon(Scalar epsilon)
Sets an epsilon to avoid division by zero.
NeuralEngine::MachineLearning::NadamSolver::SetDecay
void SetDecay(Scalar decay)
Sets initial decay rate.
NeuralEngine::MachineLearning::NadamSolver::~NadamSolver
~NadamSolver()
Destructor.
NeuralEngine::MachineLearning::NadamSolver::SetAlpha
void SetAlpha(Scalar alpha)
Sets the learning rate.
NeuralEngine::MachineLearning::NadamSolver::NadamSolver
NadamSolver(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::NadamSolver::GetEpsilon
Scalar GetEpsilon()
Gets the epsilon.
NeuralEngine::MachineLearning::NadamSolver::GetBeta2
Scalar GetBeta2()
Gets decay rate for the second-moment estimates.
NeuralEngine::MachineLearning::NadamSolver::GetDecay
Scalar GetDecay()
Gets the initial decay.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction
Definition: NonlinearObjectiveFunction.h:21
Scalar
NeuralEngine
Definition: NeArray2.h:18