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

FgSparseDeepGPSSMBaseModel.h
1
11#pragma once
12
13#include <MachineLearning/FgGPStateSpaceBaseModel.h>
14#include <MachineLearning/FgSparseGPBaseLayer.h>
15
16 namespace NeuralEngine
17{
18 namespace MachineLearning
19 {
20 namespace GPModels
21 {
22 namespace PowerEP
23 {
24 template<typename Scalar>
25 class SGPLayer;
26 }
27
28 namespace AEP
29 {
30 template<typename Scalar>
31 class SGPLayer;
32 }
33
34 //namespace VFE
35 //{
36 // //template<Scalar>
37 // class SGPLayer;
38 //}
39
48 template<typename Scalar>
49 class NE_IMPEXP SparseDeepGPSSMBaseModel : public GPSSBaseModel<Scalar>
50 {
51 public:
52
63 SparseDeepGPSSMBaseModel(const af::array& Y, int latentDimension, HiddenLayerDescription description,
64 Scalar priorMean = 0.0, Scalar priorVariance = 1.0, af::array& xControl = af::array(), PropagationMode probMode = PropagationMode::MomentMatching,
65 LogLikType lType = LogLikType::Gaussian, XInit emethod = XInit::pca);
66
77 SparseDeepGPSSMBaseModel(const af::array& Y, int latentDimension, std::vector<HiddenLayerDescription> descriptions,
78 Scalar priorMean = 0.0, Scalar priorVariance = 1.0, af::array& xControl = af::array(), PropagationMode probMode = PropagationMode::MomentMatching,
79 LogLikType lType = LogLikType::Gaussian, XInit emethod = XInit::pca);
80
87 SparseDeepGPSSMBaseModel();
88
94 virtual ~SparseDeepGPSSMBaseModel();
95
103 virtual bool Init() override;
104
114 virtual void PredictF(const af::array& testInputs, af::array& mf, af::array& vf) override;
115
127 virtual void PredictForward(int numTimeSamples, af::array& my, af::array& vy, int numSamples = 200,
128 af::array* mx = nullptr, af::array* vx = nullptr);
129
139 //virtual void SampleY(const af::array inputs, int numSamples, af::array& outFunctions) override;
140
148 virtual int GetNumParameters() override;
149
157 virtual int GetNumGPLayerParameters();
158
166 virtual void SetParameters(const af::array& param) override;
167
175 virtual af::array GetParameters() override;
176
182 virtual void UpdateParameters() override;
183
191 virtual int GetNumLayers();
192
200 virtual std::vector<SparseGPBaseLayer<Scalar>*> GetGPLayers();
201
209 virtual void FixKernelParameters(bool isfixed);
210
211
212 protected:
213 virtual void PredictForwardMM(int numTimeSamples, af::array& my, af::array& vy,
214 af::array* mx = nullptr, af::array* vx = nullptr);
215
216 virtual void PredictForwardMC(int numTimeSamples, af::array& my, af::array& vy, int numSamples = 200,
217 af::array* mx = nullptr);
218
219 int iNumLayer; //< number of gp layers
220
221 std::vector<int> vNumPseudosPerLayer;
222 std::vector<int> vSize;
223 std::vector<HiddenLayerDescription> vDescription;
224
225 SparseGPBaseLayer<Scalar>* dynLayer;
226 std::vector<SparseGPBaseLayer<Scalar>*> gpEmissLayer;
227
228 private:
229 friend class AEP::SGPLayer<Scalar>;
230 friend class PowerEP::SGPLayer<Scalar>;
231 //friend class VFE::SGPLayer/*<Scalar>*/;
232
233 friend class boost::serialization::access;
234
235 template<class Archive>
236 void serialize(Archive& ar, unsigned int version)
237 {
238 ar& boost::serialization::base_object<GPSSBaseModel<Scalar>>(*this);
239
240 //ar& boost::serialization::make_nvp("GPLVMBaseModel", boost::serialization::base_object<GPLVMBaseModel<Scalar>>(*this));
241
242 ar.register_type<AEP::SGPLayer<Scalar>>();
243 ar.register_type<PowerEP::SGPLayer<Scalar>>();
244 //ar.register_type<VFE::SGPLayer>();
245
246 ar& BOOST_SERIALIZATION_NVP(iNumLayer);
247 ar& BOOST_SERIALIZATION_NVP(vNumPseudosPerLayer);
248 ar& BOOST_SERIALIZATION_NVP(vSize);
249 ar& BOOST_SERIALIZATION_NVP(vDescription);
250 ar& BOOST_SERIALIZATION_NVP(dynLayer);
251 ar& BOOST_SERIALIZATION_NVP(gpEmissLayer);
252 }
253 };
254 }
255 }
256}
257
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::PowerEP::SGPLayer
Sparse GP layer.
Definition: FgPEPSparseGPLayer.h:38
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel
Base class with abstract and basic function definitions. All deep GP models will be derived from this...
Definition: FgSparseDeepGPSSMBaseModel.h:50
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::GetNumGPLayerParameters
virtual int GetNumGPLayerParameters()
Gets number gp layer parameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::dynLayer
SparseGPBaseLayer< Scalar > * dynLayer
sparse Gaussian Process dynamic layer
Definition: FgSparseDeepGPSSMBaseModel.h:225
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::PredictF
virtual void PredictF(const af::array &testInputs, af::array &mf, af::array &vf) override
Predict noise free functions values .
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::SparseDeepGPSSMBaseModel
SparseDeepGPSSMBaseModel()
Default Constructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::~SparseDeepGPSSMBaseModel
virtual ~SparseDeepGPSSMBaseModel()
Destructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::SetParameters
virtual void SetParameters(const af::array &param) override
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::SparseDeepGPSSMBaseModel
SparseDeepGPSSMBaseModel(const af::array &Y, int latentDimension, std::vector< HiddenLayerDescription > descriptions, Scalar priorMean=0.0, Scalar priorVariance=1.0, af::array &xControl=af::array(), PropagationMode probMode=PropagationMode::MomentMatching, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::FixKernelParameters
virtual void FixKernelParameters(bool isfixed)
Sets fixation for hyperparameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::PredictForward
virtual void PredictForward(int numTimeSamples, af::array &my, af::array &vy, int numSamples=200, af::array *mx=nullptr, af::array *vx=nullptr)
Noise-free Forward prediction.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::SparseDeepGPSSMBaseModel
SparseDeepGPSSMBaseModel(const af::array &Y, int latentDimension, HiddenLayerDescription description, Scalar priorMean=0.0, Scalar priorVariance=1.0, af::array &xControl=af::array(), PropagationMode probMode=PropagationMode::MomentMatching, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::GetParameters
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::Init
virtual bool Init() override
Initializes the model.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::GetNumParameters
virtual int GetNumParameters() override
Generate function samples from posterior.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::UpdateParameters
virtual void UpdateParameters() override
Updates the parameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::GetNumLayers
virtual int GetNumLayers()
Gets number of GP layers.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::gpEmissLayer
std::vector< SparseGPBaseLayer< Scalar > * > gpEmissLayer
sparse Gaussian Process emission layer
Definition: FgSparseDeepGPSSMBaseModel.h:226
NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel::GetGPLayers
virtual std::vector< SparseGPBaseLayer< Scalar > * > GetGPLayers()
Gets vector of GP layers.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseLayer
Abstract class for different GP likelihood layers.
Definition: FgSparseGPBaseLayer.h:35
NeuralEngine::MachineLearning::HiddenLayerDescription
Description of the layer.
Definition: FgIModel.h:36
Scalar
NeuralEngine
Definition: NeArray2.h:18