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

FgRBFKernel.h
1
11#pragma once
12
13#include <NeEngineLib.h>
14#include <MachineLearning/FgIKernel.h>
15
16 namespace NeuralEngine
17{
18 namespace MachineLearning
19 {
32 template<typename Scalar>
33 class NE_IMPEXP RBFKernel : public IKernel<Scalar>
34 {
35 public:
41 RBFKernel();
42
48 ~RBFKernel();
49
59 void ComputeKernelMatrix(const af::array& inX1, const af::array& inX2, af::array& outMatrix);
60
69 void ComputeDiagonal(const af::array& inX, af::array& outDiagonal);
70
86 void LogLikGradientX(const af::array& inX, const af::array& indL_dK, af::array& outdL_dX);
87
100 void LogLikGradientX(const af::array& inXu, const af::array& indL_dKuu, const af::array& inX, const af::array& indL_dKuf, af::array& outdL_dXu, af::array& outdL_dX);
101
112 void LogLikGradientParam(const af::array& inX1, const af::array& inX2, const af::array& indL_dK, af::array& outdL_dParam);
113
114 virtual void LogLikGradientCompundKfu(const af::array& indL_dKfu, const af::array& inX, const af::array& inXu,
115 af::array* outdL_dParam, af::array* outdL_dXu, const af::array* dlogZ_dv = nullptr, af::array* outdL_dX = nullptr) override;
116
117 virtual void LogGradientCompoundKuu(const af::array& inXu, const af::array& inCovDiag,
118 af::array* outdL_dParam, af::array* outdL_dXu) override;
119
130 void GradX(const af::array& inX1, const af::array& inX2, int q, af::array& outdK_dX);
131
140 void DiagGradX(const af::array& inX, af::array& outDiagdK_dX);
141
151 void DiagGradParam(const af::array& inX, const af::array& inCovDiag, af::array& outDiagdK_dParam);
152
160 void SetParameters(const af::array& param);
161
162 virtual void SetLogParameters(const af::array& param) override;
163
171 af::array GetParameters();
172
173 virtual af::array GetLogParameters() override;
174
178
179 void Psi1Derivative(const af::array& inPsi1, const af::array& indL_dpsi1, const af::array& inZ, const af::array& inMu,
180 const af::array& inSu, af::array& outdL_dParam, af::array& outdL_dXu, af::array* outdL_dX = nullptr);
181
182 private:
183 Scalar dVariance, dInvScale;
184
185 friend class boost::serialization::access;
186
187 template<class Archive>
188 void serialize(Archive& ar, unsigned int version)
189 {
190 ar & boost::serialization::base_object<IKernel<Scalar>>(*this);
191 ar& BOOST_SERIALIZATION_NVP(dVariance);
192 ar& BOOST_SERIALIZATION_NVP(dInvScale);
193 }
194 };
195 }
196}
NeuralEngine::MachineLearning::IKernel
Definition: FgIKernel.h:36
NeuralEngine::MachineLearning::RBFKernel
Radial basis kernel function.
Definition: FgRBFKernel.h:34
NeuralEngine::MachineLearning::RBFKernel::LogLikGradientX
void LogLikGradientX(const af::array &inX, const af::array &indL_dK, af::array &outdL_dX)
Computes dL/dX for full fit GP.
NeuralEngine::MachineLearning::RBFKernel::RBFKernel
RBFKernel()
Default constructor.
NeuralEngine::MachineLearning::RBFKernel::SetLogParameters
virtual void SetLogParameters(const af::array &param) override
Sets log parameters.
NeuralEngine::MachineLearning::RBFKernel::~RBFKernel
~RBFKernel()
Destructor.
NeuralEngine::MachineLearning::RBFKernel::SetParameters
void SetParameters(const af::array &param)
Sets the parameters.
NeuralEngine::MachineLearning::RBFKernel::LogLikGradientX
void LogLikGradientX(const af::array &inXu, const af::array &indL_dKuu, const af::array &inX, const af::array &indL_dKuf, af::array &outdL_dXu, af::array &outdL_dX)
Computes dL / dX and dL / dXu for sparse approximation GP.
NeuralEngine::MachineLearning::RBFKernel::GradX
void GradX(const af::array &inX1, const af::array &inX2, int q, af::array &outdK_dX)
Computes dK/dX.
NeuralEngine::MachineLearning::RBFKernel::DiagGradX
void DiagGradX(const af::array &inX, af::array &outDiagdK_dX)
Derivative of diagonal elemts of K w.r.t X.
NeuralEngine::MachineLearning::RBFKernel::Psi1Derivative
void Psi1Derivative(const af::array &inPsi1, const af::array &indL_dpsi1, const af::array &inZ, const af::array &inMu, const af::array &inSu, af::array &outdL_dParam, af::array &outdL_dXu, af::array *outdL_dX=nullptr)
PSI statistics.
NeuralEngine::MachineLearning::RBFKernel::ComputeKernelMatrix
void ComputeKernelMatrix(const af::array &inX1, const af::array &inX2, af::array &outMatrix)
Computes the kernel matrix of the kernel.
NeuralEngine::MachineLearning::RBFKernel::GetParameters
af::array GetParameters()
Gets the parameters.
NeuralEngine::MachineLearning::RBFKernel::LogLikGradientParam
void LogLikGradientParam(const af::array &inX1, const af::array &inX2, const af::array &indL_dK, af::array &outdL_dParam)
Computes the gradient of the kernel parameters.
NeuralEngine::MachineLearning::RBFKernel::ComputeDiagonal
void ComputeDiagonal(const af::array &inX, af::array &outDiagonal)
Calculates only diagonal elements of K.
NeuralEngine::MachineLearning::RBFKernel::GetLogParameters
virtual af::array GetLogParameters() override
Gets log parameters.
NeuralEngine::MachineLearning::RBFKernel::DiagGradParam
void DiagGradParam(const af::array &inX, const af::array &inCovDiag, af::array &outDiagdK_dParam)
Derivative of diagonal elemts of K w.r.t kernel parameters.
Scalar
NeuralEngine
Definition: NeArray2.h:18