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

FgSparseGPSSMBaseModel.h
1
11#pragma once
12
13#include <MachineLearning/FgGPStateSpaceBaseModel.h>
14#include <MachineLearning/FgSparseGPBaseLayer.h>
15#include <MachineLearning/FgGaussEmissionLayer.h>
16
17 namespace NeuralEngine
18{
19 namespace MachineLearning
20 {
21 namespace GPModels
22 {
23 template<typename Scalar>
24 class GaussEmission;
25
26 namespace PowerEP
27 {
28 template<typename Scalar>
29 class SGPLayer;
30 }
31
32 namespace AEP
33 {
34 template<typename Scalar>
35 class SGPLayer;
36 }
37
38 //namespace VFE
39 //{
40 // //template<Scalar>
41 // class SGPLayer;
42 //}
43
99 template<typename Scalar>
100 class NE_IMPEXP SparseGPSSMBaseModel : public GPSSBaseModel<Scalar>
101 {
102 public:
119 SparseGPSSMBaseModel(const af::array& Y, int latentDimension, int numInducing = 200, Scalar priorMean = 0.0,
120 Scalar priorVariance = 1.0, af::array& xControl = af::array(), PropagationMode probMode = PropagationMode::MomentMatching, LogLikType lType = LogLikType::Gaussian,
121 bool GPemission = false, bool controlToEmiss = true, XInit emethod = XInit::pca);
122
129 virtual ~SparseGPSSMBaseModel();
130
138 virtual bool Init() override;
139
149 virtual void PredictF(const af::array& testInputs, af::array& mf, af::array& vf) override;
150
160 virtual void PredictY(const af::array& testInputs, af::array& my, af::array& vy) override;
161
173 virtual void PredictForward(int numTimeSamples, af::array& my, af::array& vy,
174 af::array* mx = nullptr, af::array* vx = nullptr);
175
184 virtual void PosteriorData(af::array& my, af::array& vy);
185
193 virtual int GetNumParameters() override;
194
202 virtual void SetParameters(const af::array& param) override;
203
211 virtual af::array GetParameters() override;
212
218 virtual void UpdateParameters() override;
219
227 virtual void FixKernelParameters(bool isfixed);
228
236 virtual void FixInducing(bool isfixed);
237
238 SparseGPSSMBaseModel();
239
240 protected:
241
242 int ik;
243 SparseGPBaseLayer<Scalar>* dynLayer;
244 SparseGPBaseLayer<Scalar>* gpEmissLayer;
245 GaussEmission<Scalar>* gaussEmissLayer;
246
247 private:
248 friend class AEP::SGPLayer<Scalar>;
249 friend class PowerEP::SGPLayer<Scalar>;
250 //friend class VFE::SGPLayer/*<Scalar>*/;
251 friend class GaussEmission<Scalar>;
252
253 friend class boost::serialization::access;
254
255 template<class Archive>
256 void serialize(Archive& ar, unsigned int version)
257 {
258 ar& boost::serialization::base_object<GPSSBaseModel<Scalar>>(*this);
259
260 //ar& boost::serialization::make_nvp("GPSSBaseModel", boost::serialization::base_object<GPSSBaseModel<Scalar>>(*this));
261
262 ar.register_type<AEP::SGPLayer<Scalar>>();
263 ar.register_type<PowerEP::SGPLayer<Scalar>>();
264 //ar.register_type<VFE::SGPLayer>();
265 ar.register_type<GaussEmission<Scalar>>();
266
267 ar& BOOST_SERIALIZATION_NVP(ik);
268 ar& BOOST_SERIALIZATION_NVP(dynLayer);
269 ar& BOOST_SERIALIZATION_NVP(gpEmissLayer);
270 ar& BOOST_SERIALIZATION_NVP(gaussEmissLayer);
271 }
272 };
273
274 }
275 }
276}
NeuralEngine::MachineLearning::GPModels::AEP::SGPLayer
Sparse GP layer.
Definition: FgAEPSparseGPLayer.h:40
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel
Base class with abstract and basic function definitions. All GP state space models will be derived fr...
Definition: FgGPStateSpaceBaseModel.h:32
NeuralEngine::MachineLearning::GPModels::GaussEmission
Likelihood emission layer for State Space Models based on Gaussian distribution.
Definition: FgGaussEmissionLayer.h:67
NeuralEngine::MachineLearning::GPModels::PowerEP::SGPLayer
Sparse GP layer.
Definition: FgPEPSparseGPLayer.h:38
NeuralEngine::MachineLearning::GPModels::SparseGPBaseLayer
Abstract class for different GP likelihood layers.
Definition: FgSparseGPBaseLayer.h:35
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel
Base class for all sparse GPSSM models.
Definition: FgSparseGPSSMBaseModel.h:101
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::PredictF
virtual void PredictF(const af::array &testInputs, af::array &mf, af::array &vf) override
Predict noise free functions values .
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::GetParameters
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::GetNumParameters
virtual int GetNumParameters() override
Gets number of parameters.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::FixKernelParameters
virtual void FixKernelParameters(bool isfixed)
Sets fixation for hyperparameters.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::PosteriorData
virtual void PosteriorData(af::array &my, af::array &vy)
Get posterior distribution of latent variables /f$\mathbf{X}/f$.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::Init
virtual bool Init() override
Initializes the model.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::gpEmissLayer
SparseGPBaseLayer< Scalar > * gpEmissLayer
sparse Gaussian Process emission layer
Definition: FgSparseGPSSMBaseModel.h:244
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::SetParameters
virtual void SetParameters(const af::array &param) override
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::PredictY
virtual void PredictY(const af::array &testInputs, af::array &my, af::array &vy) override
Prediction of test outputs .
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::ik
int ik
number of inducing inputs
Definition: FgSparseGPSSMBaseModel.h:242
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::dynLayer
SparseGPBaseLayer< Scalar > * dynLayer
sparse Gaussian Process dynamic layer
Definition: FgSparseGPSSMBaseModel.h:243
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::~SparseGPSSMBaseModel
virtual ~SparseGPSSMBaseModel()
Destructor.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::UpdateParameters
virtual void UpdateParameters() override
Updates the parameters.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::SparseGPSSMBaseModel
SparseGPSSMBaseModel(const af::array &Y, int latentDimension, int numInducing=200, Scalar priorMean=0.0, Scalar priorVariance=1.0, af::array &xControl=af::array(), PropagationMode probMode=PropagationMode::MomentMatching, LogLikType lType=LogLikType::Gaussian, bool GPemission=false, bool controlToEmiss=true, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::gaussEmissLayer
GaussEmission< Scalar > * gaussEmissLayer
Gaussian distibution emission layer.
Definition: FgSparseGPSSMBaseModel.h:245
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::PredictForward
virtual void PredictForward(int numTimeSamples, af::array &my, af::array &vy, af::array *mx=nullptr, af::array *vx=nullptr)
Noise-free Forward prediction.
NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel::FixInducing
virtual void FixInducing(bool isfixed)
Set fixation for inducing inputs.
Scalar
NeuralEngine
Definition: NeArray2.h:18