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

FgStyleKernel.h
1
11#pragma once
12
13#include <MachineLearning/FgIKernel.h>
14
15 namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
33 template<typename Scalar>
34 class NE_IMPEXP StyleKernel : public IKernel<Scalar>
35 {
36 public:
42 StyleKernel();
43
51 StyleKernel(int numdims);
52
58 ~StyleKernel();
59
69 void ComputeKernelMatrix(const af::array& inX1, const af::array& inX2, af::array& outMatrix);
70
79 void ComputeDiagonal(const af::array& inX, af::array& outDiagonal);
80
96 void LogLikGradientX(const af::array& inX, const af::array& indL_dK, af::array& outdL_dX);
97
110 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);
111
122 virtual void LogLikGradientX(const af::array& inX1, const af::array& inX2, const af::array& indL_dK, af::array& outdL_dX) override;
123
134 void LogLikGradientParam(const af::array& inX1, const af::array& inX2, const af::array& indL_dK, af::array& outdL_dParam);
135
146 virtual void LogLikGradientParam(const af::array& inX1, const af::array& inX2, const af::array& indL_dK,
147 af::array& outdL_dParam, const af::array* dlogZ_dv) override;
148
159 void GradX(const af::array& inX1, const af::array& inX2, int q, af::array& outdK_dX);
160
169 void DiagGradX(const af::array& inX, af::array& outDiagdK_dX);
170
180 void DiagGradParam(const af::array& inX, const af::array& inCovDiag, af::array& outDiagdK_dParam);
181
192 virtual void InitParameters(Scalar inMedian) override;
193
194 virtual void LogLikGradientCompundKfu(const af::array& indL_dKfu, const af::array& inX, const af::array& inXu,
195 af::array* outdL_dParam, af::array* outdL_dXu, const af::array* dlogZ_dv = nullptr, af::array* outdL_dX = nullptr) override;
196
197 virtual void LogGradientCompoundKuu(const af::array& inXu, const af::array& inCovDiag,
198 af::array* outdL_dParam, af::array* outdL_dXu) override;
199
207 void SetParameters(const af::array& param);
208
216 af::array GetParameters();
217
225 virtual void SetLogParameters(const af::array& param) override;
226
234 virtual af::array GetLogParameters() override;
235
239
252 //void ComputePsiStatistics(const af::array& inXu, const af::array& inMu, const af::array& inS,
253 // af::array& outPsi0, af::array& outPsi1, af::array& outPsi2) override;
254
272 //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,
273 // const af::array& inXu, const af::array& inMu, const af::array& inS, af::array& outdL_dParam, af::array& outdL_dXu,
274 // af::array& outdL_dMu, af::array& outdL_dS, const af::array* dlogZ_dv = nullptr) override;
275
276 protected:
277
293 void Psi2Derivative(const af::array& indL_dPsi2, const af::array& inXu, const af::array& inMu,
294 const af::array& inS, af::array& outdL_dParam, af::array& outdL_dXu, af::array& outdL_dMu, af::array& outdL_dS);
295
296 private:
297 friend class boost::serialization::access;
298
299 template<class Archive>
300 void serialize(Archive& ar, unsigned int version)
301 {
302 ar& boost::serialization::base_object<IKernel<Scalar>>(*this);
303 //ar& boost::serialization::make_nvp("IKernel", boost::serialization::base_object<IKernel<Scalar>>(*this));
304 }
305 };
306 }
307}
308
NeuralEngine::MachineLearning::IKernel
Definition: FgIKernel.h:36
NeuralEngine::MachineLearning::StyleKernel
Linear style kernel function.
Definition: FgStyleKernel.h:35
NeuralEngine::MachineLearning::StyleKernel::StyleKernel
StyleKernel()
Default constructor.
NeuralEngine::MachineLearning::StyleKernel::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::StyleKernel::GetParameters
af::array GetParameters()
Gets the parameters.
NeuralEngine::MachineLearning::StyleKernel::SetLogParameters
virtual void SetLogParameters(const af::array &param) override
Sets log parameters.
NeuralEngine::MachineLearning::StyleKernel::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::StyleKernel::Psi2Derivative
void Psi2Derivative(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)
PSI statistics.
NeuralEngine::MachineLearning::StyleKernel::StyleKernel
StyleKernel(int numdims)
Constructor.
NeuralEngine::MachineLearning::StyleKernel::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::StyleKernel::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::StyleKernel::GradX
void GradX(const af::array &inX1, const af::array &inX2, int q, af::array &outdK_dX)
Computes dK/dX.
NeuralEngine::MachineLearning::StyleKernel::GetLogParameters
virtual af::array GetLogParameters() override
Gets log parameters.
NeuralEngine::MachineLearning::StyleKernel::SetParameters
void SetParameters(const af::array &param)
Sets the parameters.
NeuralEngine::MachineLearning::StyleKernel::ComputeKernelMatrix
void ComputeKernelMatrix(const af::array &inX1, const af::array &inX2, af::array &outMatrix)
Computes the kernel matrix of the kernel.
NeuralEngine::MachineLearning::StyleKernel::ComputeDiagonal
void ComputeDiagonal(const af::array &inX, af::array &outDiagonal)
Calculates only diagonal elements of K.
NeuralEngine::MachineLearning::StyleKernel::InitParameters
virtual void InitParameters(Scalar inMedian) override
Initializes the parameters based on the median of the distances of /f$\mathbf{X}/f$.
NeuralEngine::MachineLearning::StyleKernel::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::StyleKernel::~StyleKernel
~StyleKernel()
Destructor.
NeuralEngine::MachineLearning::StyleKernel::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::StyleKernel::DiagGradX
void DiagGradX(const af::array &inX, af::array &outDiagdK_dX)
Derivative of diagonal elemts of K w.r.t X.
Scalar
NeuralEngine
Definition: NeArray2.h:18