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

FgInterDomainKernel.h
1/*
2 Author:
3 Email :
4 Site :
5
6 Copyright(c) 2022 . All rights reserved.
7*/
8
9#pragma once
10
11#include <MachineLearning/FgIKernel.h>
12
13 namespace NeuralEngine
14{
15 namespace MachineLearning
16 {
40 template<typename Scalar>
41 class NE_IMPEXP InterDomainKernel : public IKernel<Scalar>
42 {
43
44 public:
50 InterDomainKernel();
51
57 ~InterDomainKernel();
58
69 void AddSubKernel(IKernel<Scalar>* kernel);
70
81 void AddWindowKernel(IKernel<Scalar>* kernel);
82
92 void ComputeKernelMatrix(const af::array& inX1, const af::array& inX2, af::array& outMatrix);
93
102 void ComputeDiagonal(const af::array& inX, af::array& outDiagonal);
103
119 void LogLikGradientX(const af::array& inX, const af::array& indL_dK, af::array& outdL_dX);
120
133 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);
134
145 virtual void LogLikGradientX(const af::array& inX1, const af::array& inX2, const af::array& indL_dK, af::array& outdL_dX) override;
146
157 void LogLikGradientParam(const af::array& inX1, const af::array& inX2, const af::array& indL_dK, af::array& outdL_dParam);
158
169 virtual void LogLikGradientParam(const af::array& inX1, const af::array& inX2, const af::array& indL_dK,
170 af::array& outdL_dParam, const af::array* dlogZ_dv) override;
171
182 void GradX(const af::array& inX1, const af::array& inX2, int q, af::array& outdK_dX);
183
192 void DiagGradX(const af::array& inX, af::array& outDiagdK_dX);
193
203 void DiagGradParam(const af::array& inX, const af::array& inCovDiag, af::array& outDiagdK_dParam);
204
212 void SetParameters(const af::array& param);
213
221 virtual void SetLogParameters(const af::array& param) override;
222
230 virtual af::array GetLogParameters() override;
231
239 af::array GetParameters();
240
251 virtual void InitParameters(Scalar inMedian) override;
252
253 virtual void LogLikGradientCompundKfu(const af::array& indL_dKfu, const af::array& inX, const af::array& inXu,
254 af::array* outdL_dParam, af::array* outdL_dXu, const af::array* dlogZ_dv = nullptr, af::array* outdL_dX = nullptr) override;
255
256 virtual void LogGradientCompoundKuu(const af::array& inXu, const af::array& inCovDiag,
257 af::array* outdL_dParam, af::array* outdL_dXu) override;
258
262
275 void ComputePsiStatistics(const af::array& inXu, const af::array& inMu, const af::array& inS,
276 af::array& outPsi0, af::array& outPsi1, af::array& outPsi2) override;
277
295 void PsiDerivatives(const af::array& indL_dPsi0, const af::array& inPsi1, const af::array& indL_dPsi1, const af::array& inPsi2, const af::array& indL_dPsi2,
296 const af::array& inXu, const af::array& inMu, const af::array& inS, af::array& outdL_dParam, af::array& outdL_dXu,
297 af::array& outdL_dMu, af::array& outdL_dS, const af::array* dlogZ_dv = nullptr) override;
298
299 private:
300 IKernel<Scalar>* kSubKernel;
301 IKernel<Scalar>* kWindowKernel;
302
303 friend class boost::serialization::access;
304
305 template<class Archive>
306 void serialize(Archive& ar, unsigned int version)
307 {
308 ar& boost::serialization::base_object<IKernel<Scalar>>(*this);
309 //ar& boost::serialization::make_nvp("IKernel", boost::serialization::base_object<IKernel<Scalar>>(*this));
310 ar& BOOST_SERIALIZATION_NVP(kSubKernel);
311 ar& BOOST_SERIALIZATION_NVP(kWindowKernel);
312 }
313 };
314
315 }
316}
NeuralEngine::MachineLearning::IKernel
Definition: FgIKernel.h:36
NeuralEngine::MachineLearning::InterDomainKernel
Inter Domain kernel function.
Definition: FgInterDomainKernel.h:42
NeuralEngine::MachineLearning::InterDomainKernel::SetLogParameters
virtual void SetLogParameters(const af::array &param) override
Sets log parameters.
NeuralEngine::MachineLearning::InterDomainKernel::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::InterDomainKernel::LogLikGradientParam
virtual void LogLikGradientParam(const af::array &inX1, const af::array &inX2, const af::array &indL_dK, af::array &outdL_dParam, const af::array *dlogZ_dv) override
Computes the gradient of LL w.r.t. the kernel parameters.
NeuralEngine::MachineLearning::InterDomainKernel::LogLikGradientX
virtual void LogLikGradientX(const af::array &inX1, const af::array &inX2, const af::array &indL_dK, af::array &outdL_dX) override
Computes dL / dX for sparse approximation GP.
NeuralEngine::MachineLearning::InterDomainKernel::GradX
void GradX(const af::array &inX1, const af::array &inX2, int q, af::array &outdK_dX)
Computes dK/dX.
NeuralEngine::MachineLearning::InterDomainKernel::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::InterDomainKernel::DiagGradX
void DiagGradX(const af::array &inX, af::array &outDiagdK_dX)
Derivative of diagonal elemts of K w.r.t X.
NeuralEngine::MachineLearning::InterDomainKernel::InterDomainKernel
InterDomainKernel()
Default constructor.
NeuralEngine::MachineLearning::InterDomainKernel::~InterDomainKernel
~InterDomainKernel()
Destructor.
NeuralEngine::MachineLearning::InterDomainKernel::ComputeKernelMatrix
void ComputeKernelMatrix(const af::array &inX1, const af::array &inX2, af::array &outMatrix)
Computes the kernel matrix of the kernel.
NeuralEngine::MachineLearning::InterDomainKernel::GetParameters
af::array GetParameters()
Gets the parameters.
NeuralEngine::MachineLearning::InterDomainKernel::InitParameters
virtual void InitParameters(Scalar inMedian) override
Initializes the parameters based on the median of the distances of /f$\mathbf{X}/f$.
NeuralEngine::MachineLearning::InterDomainKernel::AddWindowKernel
void AddWindowKernel(IKernel< Scalar > *kernel)
Adds a shared kernel object for the inducing inputs and test inputs.
NeuralEngine::MachineLearning::InterDomainKernel::ComputeDiagonal
void ComputeDiagonal(const af::array &inX, af::array &outDiagonal)
Calculates only diagonal elements of K.
NeuralEngine::MachineLearning::InterDomainKernel::SetParameters
void SetParameters(const af::array &param)
Sets the parameters.
NeuralEngine::MachineLearning::InterDomainKernel::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::InterDomainKernel::AddSubKernel
void AddSubKernel(IKernel< Scalar > *kernel)
Adds a kernel object for the inducing inputs.
NeuralEngine::MachineLearning::InterDomainKernel::ComputePsiStatistics
void ComputePsiStatistics(const af::array &inXu, const af::array &inMu, const af::array &inS, af::array &outPsi0, af::array &outPsi1, af::array &outPsi2) override
PSI statistics computation.
NeuralEngine::MachineLearning::InterDomainKernel::PsiDerivatives
void PsiDerivatives(const af::array &indL_dPsi0, const af::array &inPsi1, const af::array &indL_dPsi1, const af::array &inPsi2, const af::array &indL_dPsi2, const af::array &inXu, const af::array &inMu, const af::array &inS, af::array &outdL_dParam, af::array &outdL_dXu, af::array &outdL_dMu, af::array &outdL_dS, const af::array *dlogZ_dv=nullptr) override
Parameter and variable derivatives w.r.t. all Psi statistics.
NeuralEngine::MachineLearning::InterDomainKernel::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.
NeuralEngine::MachineLearning::InterDomainKernel::GetLogParameters
virtual af::array GetLogParameters() override
Gets log parameters.
Scalar
NeuralEngine
Definition: NeArray2.h:18