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

FgAdamSolver.h
1
11#pragma once
12
13#include <MachineLearning/BaseGradientOptimizationMethod.h>
14
15 namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
73 template<typename Scalar, LineSearchType LSType = MoreThuente>
74 class NE_IMPEXP AdamSolver : public BaseGradientOptimizationMethod<Scalar, LSType>
75 {
76 public:
77
87 AdamSolver(int numberOfVariables);
88
100 AdamSolver(int numberOfVariables,
101 std::function<Scalar(const af::array&, af::array&)> function);
102
110 AdamSolver(NonlinearObjectiveFunction<Scalar>* function);
111
117 ~AdamSolver();
118
126 void SetBeta1(Scalar beta1);
127
135 void SetBeta2(Scalar beta2);
136
144 void SetAlpha(Scalar alpha);
145
153 void SetEpsilon(Scalar epsilon);
154
162 void SetDecay(Scalar decay);
163
171 Scalar GetBeta1();
172
180 Scalar GetBeta2();
181
189 Scalar GetAlpha();
190
198 Scalar GetEpsilon();
199
207 Scalar GetDecay();
208
209 protected:
210
221 virtual bool Optimize(int* cycle = nullptr) override;
222
223 private:
224 Scalar min_step; // The minimum step length allowed in the line search.
225 Scalar max_step; // The maximum step length allowed in the line search.
226
227 Scalar sAlpha; // learning rate
228 Scalar sBeta1; // exponential decay rate for the first moment estimates (e.g. 0.9)
229 Scalar sBeta2; // exponential decay rate for the second-moment estimates (e.g. 0.999).
230 Scalar sEpsilon; // small number to prevent any division by zero in the implementation
231 Scalar sDecay;
232 Scalar delta;
233 };
234 }
235}
NeuralEngine::MachineLearning::AdamSolver
Adam optimizer.
Definition: FgAdamSolver.h:75
NeuralEngine::MachineLearning::AdamSolver::AdamSolver
AdamSolver(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::AdamSolver::GetAlpha
Scalar GetAlpha()
Gets the learning rate.
NeuralEngine::MachineLearning::AdamSolver::GetBeta1
Scalar GetBeta1()
Gets decay rate for the first moment estimates.
NeuralEngine::MachineLearning::AdamSolver::SetDecay
void SetDecay(Scalar decay)
Sets initial decay rate.
NeuralEngine::MachineLearning::AdamSolver::SetBeta2
void SetBeta2(Scalar beta2)
Sets decay rate for the second-moment estimates.
NeuralEngine::MachineLearning::AdamSolver::SetEpsilon
void SetEpsilon(Scalar epsilon)
Sets an epsilon to avoid division by zero.
NeuralEngine::MachineLearning::AdamSolver::SetAlpha
void SetAlpha(Scalar alpha)
Sets the learning rate.
NeuralEngine::MachineLearning::AdamSolver::GetEpsilon
Scalar GetEpsilon()
Gets the epsilon.
NeuralEngine::MachineLearning::AdamSolver::~AdamSolver
~AdamSolver()
Destructor.
NeuralEngine::MachineLearning::AdamSolver::AdamSolver
AdamSolver(int numberOfVariables)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::AdamSolver::Optimize
virtual bool Optimize(int *cycle=nullptr) override
Implements the actual optimization algorithm. This method should try to minimize the objective functi...
NeuralEngine::MachineLearning::AdamSolver::GetBeta2
Scalar GetBeta2()
Gets decay rate for the second-moment estimates.
NeuralEngine::MachineLearning::AdamSolver::SetBeta1
void SetBeta1(Scalar beta1)
Sets decay rate for the first moment estimates.
NeuralEngine::MachineLearning::AdamSolver::GetDecay
Scalar GetDecay()
Gets the initial decay.
NeuralEngine::MachineLearning::AdamSolver::AdamSolver
AdamSolver(NonlinearObjectiveFunction< Scalar > *function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod
Base class for gradient-based optimization methods.
Definition: BaseGradientOptimizationMethod.h:40
NeuralEngine::MachineLearning::NonlinearObjectiveFunction
Definition: NonlinearObjectiveFunction.h:21
Scalar
NeuralEngine
Definition: NeArray2.h:18