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

FgSparseDeepGPLVMBaseModel.h
1
11#pragma once
12
13#include <MachineLearning/FgGPLVMBaseModel.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 SparseDeepGPLVMBaseModel : public GPLVMBaseModel<Scalar>
50 {
51 public:
52
63 SparseDeepGPLVMBaseModel(const af::array& Y, int latentDimension, HiddenLayerDescription description,
64 Scalar priorMean = 0.0, Scalar priorVariance = 1.0, LogLikType lType = LogLikType::Gaussian, XInit emethod = XInit::pca);
65
76 SparseDeepGPLVMBaseModel(const af::array& Y, int latentDimension, std::vector<HiddenLayerDescription> descriptions,
77 Scalar priorMean = 0.0, Scalar priorVariance = 1.0, LogLikType lType = LogLikType::Gaussian, XInit emethod = XInit::pca);
78
85 SparseDeepGPLVMBaseModel();
86
92 virtual ~SparseDeepGPLVMBaseModel();
93
101 virtual bool Init() override;
102
112 virtual void PredictF(const af::array& testInputs, af::array& mf, af::array& vf) override;
113
123 virtual void SampleY(const af::array inputs, int numSamples, af::array& outFunctions) override;
124
132 virtual int GetNumParameters() override;
133
141 virtual int GetNumGPLayerParameters();
142
150 virtual void SetParameters(const af::array& param) override;
151
159 virtual af::array GetParameters() override;
160
166 virtual void UpdateParameters() override;
167
175 virtual int GetNumLayers();
176
184 virtual std::vector<SparseGPBaseLayer<Scalar>*> GetGPLayers();
185
193 virtual void FixKernelParameters(bool isfixed);
194
195
196 protected:
197 int iNumLayer; //< number of gp layers
198
199 std::vector<int> vNumPseudosPerLayer;
200 std::vector<int> vSize;
201 std::vector<HiddenLayerDescription> vDescription;
202
203 std::vector<SparseGPBaseLayer<Scalar>*> gpLayer;
204
205 private:
206 friend class AEP::SGPLayer<Scalar>;
207 friend class PowerEP::SGPLayer<Scalar>;
208 //friend class VFE::SGPLayer/*<Scalar>*/;
209
210 friend class boost::serialization::access;
211
212 template<class Archive>
213 void serialize(Archive& ar, unsigned int version)
214 {
215 ar& boost::serialization::base_object<GPLVMBaseModel<Scalar>>(*this);
216
217 //ar& boost::serialization::make_nvp("GPLVMBaseModel", boost::serialization::base_object<GPLVMBaseModel<Scalar>>(*this));
218
219 ar.register_type<AEP::SGPLayer<Scalar>>();
220 ar.register_type<PowerEP::SGPLayer<Scalar>>();
221 //ar.register_type<VFE::SGPLayer>();
222
223 ar& BOOST_SERIALIZATION_NVP(iNumLayer);
224 ar& BOOST_SERIALIZATION_NVP(vNumPseudosPerLayer);
225 ar& BOOST_SERIALIZATION_NVP(vSize);
226 ar& BOOST_SERIALIZATION_NVP(vDescription);
227 ar& BOOST_SERIALIZATION_NVP(gpLayer);
228 }
229 };
230 }
231 }
232}
NeuralEngine::MachineLearning::GPModels::AEP::SGPLayer
Sparse GP layer.
Definition: FgAEPSparseGPLayer.h:40
NeuralEngine::MachineLearning::GPModels::GPLVMBaseModel
Base class with abstract and basic function definitions. All deep GP models will be derived from this...
Definition: FgGPLVMBaseModel.h:295
NeuralEngine::MachineLearning::GPModels::PowerEP::SGPLayer
Sparse GP layer.
Definition: FgPEPSparseGPLayer.h:38
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel
Base class with abstract and basic function definitions. All deep GP models will be derived from this...
Definition: FgSparseDeepGPLVMBaseModel.h:50
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::SampleY
virtual void SampleY(const af::array inputs, int numSamples, af::array &outFunctions) override
Generate function samples from posterior.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::PredictF
virtual void PredictF(const af::array &testInputs, af::array &mf, af::array &vf) override
Predict noise free functions values .
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::GetGPLayers
virtual std::vector< SparseGPBaseLayer< Scalar > * > GetGPLayers()
Gets vector of GP layers.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::Init
virtual bool Init() override
Initializes the model.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::SetParameters
virtual void SetParameters(const af::array &param) override
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::GetNumGPLayerParameters
virtual int GetNumGPLayerParameters()
Gets number gp layer parameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::UpdateParameters
virtual void UpdateParameters() override
Updates the parameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::~SparseDeepGPLVMBaseModel
virtual ~SparseDeepGPLVMBaseModel()
Destructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::SparseDeepGPLVMBaseModel
SparseDeepGPLVMBaseModel()
Default Constructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::GetNumParameters
virtual int GetNumParameters() override
Gets number of parameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::GetParameters
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::GetNumLayers
virtual int GetNumLayers()
Gets number of GP layers.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::FixKernelParameters
virtual void FixKernelParameters(bool isfixed)
Sets fixation for hyperparameters.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::SparseDeepGPLVMBaseModel
SparseDeepGPLVMBaseModel(const af::array &Y, int latentDimension, std::vector< HiddenLayerDescription > descriptions, Scalar priorMean=0.0, Scalar priorVariance=1.0, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel::SparseDeepGPLVMBaseModel
SparseDeepGPLVMBaseModel(const af::array &Y, int latentDimension, HiddenLayerDescription description, Scalar priorMean=0.0, Scalar priorVariance=1.0, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::HiddenLayerDescription
Description of the layer.
Definition: FgIModel.h:36
Scalar
NeuralEngine
Definition: NeArray2.h:18