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

FgGPStateSpaceBaseModel.h
1
11#pragma once
12
13//#include <MachineLearning/FgINode.h>
14#include <MachineLearning/FgGPBaseModel.h>
15
16 namespace NeuralEngine
17{
18 namespace MachineLearning
19 {
20 namespace GPModels
21 {
30 template<typename Scalar>
31 class NE_IMPEXP GPSSBaseModel : public GPBaseModel<Scalar>, public GPNode<Scalar>
32 {
33 public:
48 GPSSBaseModel(const af::array& Y, int latentDimension, Scalar priorMean = 0.0,
49 Scalar priorVariance = 1.0, af::array& xControl = af::array(), PropagationMode probMode = PropagationMode::MomentMatching,
50 LogLikType lType = LogLikType::Gaussian, bool GPemission = true, bool controlToEmiss = true, XInit emethod = XInit::pca);
51
57 GPSSBaseModel();
58
64 virtual ~GPSSBaseModel();
65
79 virtual void Optimise(
80 OptimizerType method = L_BFGS,
81 Scalar tol = 0.0,
82 bool reinit_hypers = true,
83 int maxiter = 1000,
84 int mb_size = 0,
85 LineSearchType lsType = MoreThuente,
86 bool disp = true,
87 int* cycle = nullptr
88 ) override;
89
97 virtual bool Init(af::array& mx);
98
108 virtual void PosteriorLatents(af::array& mx, af::array& vx);
109
117 virtual int GetNumParameters() override;
118
126 virtual void SetParameters(const af::array& param) override;
127
135 virtual af::array GetParameters() override;
136
142 void UpdateDynamicIndexes();
143
144 void GetLatents(af::array& mx, af::array& vx);
145
146 virtual void AddWindowData(af::array data);
147
148 protected:
157 virtual af::array PosteriorGradientLatents(const af::array& dmx, const af::array& dvx);
158
164 virtual void UpdateParametersInternal();
165
166 int iq;
167 int iDControlEmiss;
168 int iDControlDyn;
169
170 Scalar dSn;
171
172 bool bGPemission;
173 bool bControlToEmiss;
174
175 Scalar dPriorMean;
176 Scalar dPriorVariance;
177 Scalar dPriorX1;
178 Scalar dPriorX2;
179
180 af::array afFactorX1;
181 af::array afFactorX2;
182 af::array afPosteriorX1;
183 af::array afPosteriorX2;
184 af::array afXControl;
185 af::array afDynIndexes;
186
187 af::array afPriorX1;
188 af::array afPriorX2;
189 af::array afPriorX1Cav;
190 af::array afPriorX2Cav;
191 af::array afPriorMean;
192 af::array afPriorVariance;
193 af::array afPriorMeanCav;
194 af::array afPriorVarianceCav;
195 af::array afGradMean;
196 af::array afGradVariance;
197 af::array afGradMeanCav;
198 af::array afGradVarianceCav;
199
200 af::array afLatentGradientX;
201
203
204 //af::array afIndexes; //!< indexes of /f$\mathbf{X}/f$ for batch learning
205 XInit eEmMethod;
206
207 PropagationMode pMode;
208 private:
209 friend class boost::serialization::access;
210
211 template<class Archive>
212 void serialize(Archive& ar, unsigned int version)
213 {
214 ar& boost::serialization::base_object<GPBaseModel<Scalar>>(*this);
215 //ar& boost::serialization::make_nvp("GPLVMBaseModel", boost::serialization::base_object<GPLVMBaseModel<Scalar>>(*this));
216
217 ar& BOOST_SERIALIZATION_NVP(iq);
218 ar& BOOST_SERIALIZATION_NVP(iDControlEmiss);
219 ar& BOOST_SERIALIZATION_NVP(iDControlDyn);
220 ar& BOOST_SERIALIZATION_NVP(bGPemission);
221 ar& BOOST_SERIALIZATION_NVP(bControlToEmiss);
222 ar& BOOST_SERIALIZATION_NVP(afXControl);
223 ar& BOOST_SERIALIZATION_NVP(afDynIndexes);
224 ar& BOOST_SERIALIZATION_NVP(dPriorMean);
225 ar& BOOST_SERIALIZATION_NVP(dPriorVariance);
226 ar& BOOST_SERIALIZATION_NVP(afFactorX1);
227 ar& BOOST_SERIALIZATION_NVP(afFactorX2);
228 ar& BOOST_SERIALIZATION_NVP(eEmMethod);
229 ar& BOOST_SERIALIZATION_NVP(pMode);
230 }
231 };
232 }
233 }
234}
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::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::GPSSBaseModel::PosteriorLatents
virtual void PosteriorLatents(af::array &mx, af::array &vx)
Get posterior distribution of latent variables /f$\mathbf{X}/f$.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::dPriorX1
Scalar dPriorX1
prior /f$x_1/f$
Definition: FgGPStateSpaceBaseModel.h:177
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afFactorX2
af::array afFactorX2
natural parameter factor 2 for latent variable
Definition: FgGPStateSpaceBaseModel.h:181
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorVarianceCav
af::array afPriorVarianceCav
prior variance for hierarchy mode
Definition: FgGPStateSpaceBaseModel.h:194
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::UpdateDynamicIndexes
void UpdateDynamicIndexes()
Updates the dynamic indexes.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::dPriorVariance
Scalar dPriorVariance
prior variance
Definition: FgGPStateSpaceBaseModel.h:176
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::SetParameters
virtual void SetParameters(const af::array &param) override
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::GetParameters
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::GetNumParameters
virtual int GetNumParameters() override
Gets number of parameters.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afGradVarianceCav
af::array afGradVarianceCav
prior variance gradient for hiersrchy mode
Definition: FgGPStateSpaceBaseModel.h:198
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::dPriorMean
Scalar dPriorMean
prior mean
Definition: FgGPStateSpaceBaseModel.h:175
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::GPSSBaseModel
GPSSBaseModel(const af::array &Y, int latentDimension, Scalar priorMean=0.0, Scalar priorVariance=1.0, af::array &xControl=af::array(), PropagationMode probMode=PropagationMode::MomentMatching, LogLikType lType=LogLikType::Gaussian, bool GPemission=true, bool controlToEmiss=true, XInit emethod=XInit::pca)
Constructor.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPosteriorX2
af::array afPosteriorX2
posterior natural parameter 2 for latent variable
Definition: FgGPStateSpaceBaseModel.h:183
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorX1
af::array afPriorX1
prior /f$x_1/f$
Definition: FgGPStateSpaceBaseModel.h:187
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::UpdateParametersInternal
virtual void UpdateParametersInternal()
Updates the parameters.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorX2
af::array afPriorX2
prior /f$x_2/f$
Definition: FgGPStateSpaceBaseModel.h:188
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::PosteriorGradientLatents
virtual af::array PosteriorGradientLatents(const af::array &dmx, const af::array &dvx)
Posterior gradient of latent inputs /f$\mathbf{X}/f$.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPosteriorX1
af::array afPosteriorX1
posterior natural parameter 1 for latent variable
Definition: FgGPStateSpaceBaseModel.h:182
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afGradVariance
af::array afGradVariance
prior variance gradient for hiersrchy mode
Definition: FgGPStateSpaceBaseModel.h:196
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorVariance
af::array afPriorVariance
prior variance for hierarchy mode
Definition: FgGPStateSpaceBaseModel.h:192
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afGradMean
af::array afGradMean
prior mean gradient for hiersrchy mode
Definition: FgGPStateSpaceBaseModel.h:195
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::~GPSSBaseModel
virtual ~GPSSBaseModel()
Destructor.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afFactorX1
af::array afFactorX1
natural parameter factor 1 for latent variable
Definition: FgGPStateSpaceBaseModel.h:180
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorMean
af::array afPriorMean
prior mean for hierarchy mode
Definition: FgGPStateSpaceBaseModel.h:191
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorX1Cav
af::array afPriorX1Cav
prior /f$x_1/f$
Definition: FgGPStateSpaceBaseModel.h:189
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::dPriorX2
Scalar dPriorX2
prior /f$x_2/f$
Definition: FgGPStateSpaceBaseModel.h:178
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afLatentGradientX
af::array afLatentGradientX
top down gradient
Definition: FgGPStateSpaceBaseModel.h:200
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::iq
int iq
latent dimension
Definition: FgGPStateSpaceBaseModel.h:166
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::Optimise
virtual void Optimise(OptimizerType method=L_BFGS, Scalar tol=0.0, bool reinit_hypers=true, int maxiter=1000, int mb_size=0, LineSearchType lsType=MoreThuente, bool disp=true, int *cycle=nullptr) override
Optimizes the model parameters for best fit.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorMeanCav
af::array afPriorMeanCav
prior mean for hierarchy mode
Definition: FgGPStateSpaceBaseModel.h:193
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::GPSSBaseModel
GPSSBaseModel()
Default constructor.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afGradMeanCav
af::array afGradMeanCav
prior mean gradient for hiersrchy mode
Definition: FgGPStateSpaceBaseModel.h:197
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::afPriorX2Cav
af::array afPriorX2Cav
prior /f$x_2/f$
Definition: FgGPStateSpaceBaseModel.h:190
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel::Init
virtual bool Init(af::array &mx)
Initializes the model.
NeuralEngine::MachineLearning::GPNode
This class represents grouping nodes in a hiearchy.
Definition: FgGPNode.h:42
Scalar
NeuralEngine
Definition: NeArray2.h:18