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

FgSparseGPBaseModel.h
1
11#pragma once
12
13#include <MachineLearning/FgGPBaseModel.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
57 template<typename Scalar>
58 class NE_IMPEXP SparseGPBaseModel : public GPBaseModel<Scalar>
59 {
60 public:
61
72 SparseGPBaseModel(const af::array& Y, const af::array& X, int numInducing = 200, LogLikType lType = LogLikType::Gaussian);
73
79 SparseGPBaseModel();
80
86 virtual ~SparseGPBaseModel();
87
97 virtual void PredictF(const af::array& testInputs, af::array& mf, af::array& vf) override;
98
108 virtual void SampleY(const af::array inputs, int numSamples, af::array& outFunctions) override;
109
117 af::array GetTrainingInputs();
118
126 void SetTrainingInputs(af::array& inputs);
127
135 af::array GetPseudoInputs();
136
144 virtual bool Init() override;
145
153 virtual int GetNumParameters() override;
154
162 virtual void SetParameters(const af::array& param) override;
163
171 virtual af::array GetParameters() override;
172
178 virtual void UpdateParameters() override;
179
187 virtual void FixKernelParameters(bool isfixed);
188
196 virtual void FixInducing(bool isfixed);
197
205 SparseGPBaseLayer<Scalar>* GetGPLayer();
206
207 protected:
208 int ik;
209 int iq;
210 af::array afX;
211
212 SparseGPBaseLayer<Scalar>* gpLayer;
213
214 private:
215 friend class AEP::SGPLayer<Scalar>;
216 friend class PowerEP::SGPLayer<Scalar>;
217 //friend class VFE::SGPLayer/*<Scalar>*/;
218
219 friend class boost::serialization::access;
220
221 template<class Archive>
222 void serialize(Archive& ar, unsigned int version)
223 {
224 ar& boost::serialization::base_object<GPBaseModel<Scalar>>(*this);
225
226 //ar& boost::serialization::make_nvp("GPBaseModel", boost::serialization::base_object<GPBaseModel<Scalar>>(*this));
227
228 ar.register_type<AEP::SGPLayer<Scalar>>();
229 ar.register_type<PowerEP::SGPLayer<Scalar>>();
230 /*ar.register_type<VFE::SGPLayer>();*/
231
232 ar& BOOST_SERIALIZATION_NVP(ik);
233 ar& BOOST_SERIALIZATION_NVP(iq);
234 ar& BOOST_SERIALIZATION_NVP(afX);
235 ar& BOOST_SERIALIZATION_NVP(gpLayer);
236 }
237 };
238 }
239 }
240}
NeuralEngine::MachineLearning::GPModels::AEP::SGPLayer
Sparse GP layer.
Definition: FgAEPSparseGPLayer.h:40
NeuralEngine::MachineLearning::GPModels::GPBaseModel
Base class with abstract and basic function definitions. All GP models will be derived from this clas...
Definition: FgGPBaseModel.h:40
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::SparseGPBaseModel
Base class for all sparse GP models.
Definition: FgSparseGPBaseModel.h:59
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::afX
af::array afX
training inputs
Definition: FgSparseGPBaseModel.h:210
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::SparseGPBaseModel
SparseGPBaseModel(const af::array &Y, const af::array &X, int numInducing=200, LogLikType lType=LogLikType::Gaussian)
Constructor.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::GetTrainingInputs
af::array GetTrainingInputs()
Gets training inputs X.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::GetPseudoInputs
af::array GetPseudoInputs()
Gets pseudo inputs.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::~SparseGPBaseModel
virtual ~SparseGPBaseModel()
Destructor.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::SparseGPBaseModel
SparseGPBaseModel()
Default constructor.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::UpdateParameters
virtual void UpdateParameters() override
Updates the parameters.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::gpLayer
SparseGPBaseLayer< Scalar > * gpLayer
gp layer
Definition: FgSparseGPBaseModel.h:212
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::FixInducing
virtual void FixInducing(bool isfixed)
Set fixation for inducing inputs.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::SetParameters
virtual void SetParameters(const af::array &param) override
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::Init
virtual bool Init() override
Initializes the model.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::PredictF
virtual void PredictF(const af::array &testInputs, af::array &mf, af::array &vf) override
Predict noise free functions values .
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::GetNumParameters
virtual int GetNumParameters() override
Gets number of parameters.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::iq
int iq
latent dimension
Definition: FgSparseGPBaseModel.h:209
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::ik
int ik
number of inducing inputs
Definition: FgSparseGPBaseModel.h:208
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::GetGPLayer
SparseGPBaseLayer< Scalar > * GetGPLayer()
Gets the gp layer.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::FixKernelParameters
virtual void FixKernelParameters(bool isfixed)
Sets fixation for hyperparameters.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::SampleY
virtual void SampleY(const af::array inputs, int numSamples, af::array &outFunctions) override
Generate function samples from posterior.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::GetParameters
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel::SetTrainingInputs
void SetTrainingInputs(af::array &inputs)
Gets training inputs X.
Scalar
NeuralEngine
Definition: NeArray2.h:18