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

BaseGradientOptimizationMethod.h
1
11#pragma once
12
13#include <NeMachineLearningLib.h>
14#include <MachineLearning/BaseOptimizationMethod.h>
15#include <MachineLearning/FgILineSearch.h>
16
17 namespace NeuralEngine
18{
19 namespace MachineLearning
20 {
21
22 enum LineSearchType
23 {
24 ArmijoBacktracking,
25 ArmijoBracketing,
26 MoreThuente,
27 StrongWolfeBacktracking,
28 StrongWolfeBracketing,
29 WolfeBacktracking,
30 WolfeBracketing
31 };
32
38 template<typename Scalar, LineSearchType LSType = MoreThuente>
39 class NE_IMPEXP BaseGradientOptimizationMethod : public BaseOptimizationMethod<Scalar>//, public IGradientOptimizationMethod<Scalar>
40 {
41 public:
42 /*/// <summary>
47 public CancellationToken Token{ get; set; }*/
48
57 //virtual int GetNumberOfVariables() override;
58
69 //virtual af::array GetSolution() override;
70
81 //virtual void SetSolution(af::array& x) override;
82
99 //virtual bool Maximize(af::array& values) override;
100
117 //virtual bool Minimize(af::array& values) override;
118
134 //virtual bool Maximize() override;
135
151 //virtual bool Minimize() override;
152
163 Scalar GetTolerance();
164
175 void SetTolerance(Scalar tolerance);
176
187 int GetMaxIterations();
188
199 void SetMaxIterations(int iter);
200
211 int GetIterations();
212
213 ~BaseGradientOptimizationMethod();
214
215 protected:
216
228 BaseGradientOptimizationMethod(int numberOfVariables);
229
247 BaseGradientOptimizationMethod(int numberOfVariables,
248 std::function<Scalar(const af::array&, af::array&)> function);//, std::function<af::array(const af::array&)> gradient);
249
259 BaseGradientOptimizationMethod(NonlinearObjectiveFunction<Scalar>* function);
260
266 void InitLinesearch();
267
268 //std::function<af::array(af::array&)> _gradient;
269
270 int maxIterations;
271 Scalar _tolerance;
272 int iterations;
273
274 ILineSearch<Scalar>* linesearch;
275 };
276 }
277}
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod
Base class for gradient-based optimization methods.
Definition: BaseGradientOptimizationMethod.h:40
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::BaseGradientOptimizationMethod
BaseGradientOptimizationMethod(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Initializes a new instance of the BaseGradientOptimizationMethod class.
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::GetMaxIterations
int GetMaxIterations()
Gets the maximum number of iterations to be performed during optimization. Default is 0 (iterate unti...
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::GetTolerance
Scalar GetTolerance()
Gets the relative difference threshold to be used as stopping criteria between two iterations....
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::SetMaxIterations
void SetMaxIterations(int iter)
Sets the maximum number of iterations to be performed during optimization. Default is 0 (iterate unti...
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::SetTolerance
void SetTolerance(Scalar tolerance)
Sets the relative difference threshold to be used as stopping criteria between two iterations....
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::InitLinesearch
void InitLinesearch()
Inits linesearch.
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::BaseGradientOptimizationMethod
BaseGradientOptimizationMethod(NonlinearObjectiveFunction< Scalar > *function)
Initializes a new instance of the BaseGradientOptimizationMethod class.
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::BaseGradientOptimizationMethod
BaseGradientOptimizationMethod(int numberOfVariables)
Initializes a new instance of the BaseGradientOptimizationMethod class.
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod::GetIterations
int GetIterations()
Gets the number of iterations performed in the last call to IOptimizationMethod.Minimize().
NeuralEngine::MachineLearning::BaseOptimizationMethod
Base class for optimization methods.
Definition: BaseOptimizationMethod.h:31
NeuralEngine::MachineLearning::ILineSearch
Definition: FgILineSearch.h:23
NeuralEngine::MachineLearning::NonlinearObjectiveFunction
Definition: NonlinearObjectiveFunction.h:21
Scalar
NeuralEngine
Definition: NeArray2.h:18