NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar > Class Template Reference


Base class with abstract and basic function definitions. All GP state space models will be derived from this class.
More...

#include <FgGPStateSpaceBaseModel.h>

Inheritance diagram for NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >:
Collaboration diagram for NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >:

Public Member Functions

 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. More...
 
 GPSSBaseModel ()
 Default constructor. More...
 
virtual ~GPSSBaseModel ()
 Destructor. More...
 
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. More...
 
virtual bool Init (af::array &mx)
 Initializes the model. More...
 
virtual void PosteriorLatents (af::array &mx, af::array &vx)
 Get posterior distribution of latent variables /f$\mathbf{X}/f$. More...
 
virtual int GetNumParameters () override
 Gets number of parameters. More...
 
virtual void SetParameters (const af::array &param) override
 Sets the parameters for each optimization iteration. More...
 
virtual af::array GetParameters () override
 Gets the parameters for each optimization iteration. More...
 
void UpdateDynamicIndexes ()
 Updates the dynamic indexes. More...
 
void GetLatents (af::array &mx, af::array &vx)
 
virtual void AddWindowData (af::array data)
 
- Public Member Functions inherited from NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >
 GPBaseModel (const af::array &Y, LogLikType lType=LogLikType::Gaussian, ModelType mtype=ModelType::GPR)
 Constructor. More...
 
 GPBaseModel ()
 Default Constructor. More...
 
virtual ~GPBaseModel ()
 Destructor. More...
 
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)
 Optimizes the model parameters for best fit. More...
 
virtual bool Init ()
 Initializes the model. More...
 
virtual void PredictF (const af::array &testInputs, af::array &mf, af::array &vf)
 Predict noise free functions values \(\mathbf{F}_*\). More...
 
virtual void PredictY (const af::array &testInputs, af::array &my, af::array &vy)
 Prediction of test outputs \(\mathbf{Y}_*\). More...
 
virtual void SampleY (const af::array inputs, int numSamples, af::array &outFunctions)
 Generate function samples from posterior. More...
 
virtual void AddData (const af::array Ytrain)
 Adds training data to the model. More...
 
af::array GetTrainingData ()
 Gets the training data set Y. More...
 
void SetTrainingData (af::array &data)
 Sets training data Y. More...
 
virtual int GetNumParameters ()
 Gets number of parameters. More...
 
virtual void SetParameters (const af::array &param)
 Sets the parameters for each optimization iteration. More...
 
virtual af::array GetParameters ()
 Gets the parameters for each optimization iteration. More...
 
virtual void UpdateParameters ()
 Updates the parameters. More...
 
virtual void FixLikelihoodParameters (bool isfixed)
 Sets the likelihood parameters to be fixed or not for optimization. More...
 
void SetSegments (af::array segments)
 Sets fixation for hyperparameters. More...
 
af::array GetSegments ()
 Gets the start index array for the sequences. More...
 
- Public Member Functions inherited from NeuralEngine::MachineLearning::IModel< Scalar >
virtual Scalar Function (const af::array &x, af::array &outGradient)
 Cost function the given x inputs. More...
 
virtual int GetNumParameters ()=0
 Gets number of parameters to be optimized. More...
 
virtual void SetParameters (const af::array &param)=0
 Sets the parameters for each optimization iteration. More...
 
virtual af::array GetParameters ()=0
 Gets the parameters for each optimization iteration. More...
 
virtual void UpdateParameters ()=0
 Updates the parameters. More...
 
int GetDataLenght ()
 Gets data lenght. More...
 
int GetDataDimensionality ()
 Gets data dimensionality. More...
 
ModelType GetModelType ()
 Gets model type. More...
 
virtual void SetBatchSize (int size)
 Sets batch size. More...
 
int GetBatchSize ()
 Gets batch size. More...
 
void SetIndexes (af::array &indexes)
 Sets the batch indexes. More...
 
- Public Member Functions inherited from NeuralEngine::MachineLearning::GPNode< Scalar >
 GPNode ()
 Default constructor. More...
 
virtual ~GPNode ()
 Destructor. More...
 
int GetNumChildren () const
 Gets the number of children of this item. More...
 
int AttachChild (std::shared_ptr< GPNode< Scalar > > const &child)
 Attaches a child. More...
 
int DetachChild (std::shared_ptr< GPNode< Scalar > > const &child)
 Detaches a child. More...
 
std::shared_ptr< GPNode< Scalar > > DetachChildAt (int i)
 Detaches a child at index. More...
 
void DetachAllChildren ()
 Detach all children from this node. More...
 
std::shared_ptr< GPNode< Scalar > > SetChild (int i, std::shared_ptr< GPNode< Scalar > > const &child)
 Sets a child. More...
 
std::shared_ptr< GPNode< Scalar > > GetChild (int i)
 Gets a child at index. More...
 
GPNode< Scalar > * GetParent ()
 Access to the parent object, which is null for the root of the hierarchy. More...
 
void SetParent (GPNode< Scalar > *parent)
 
Access to the parent object. Node calls this during attach/detach of children. More...
 

Protected Member Functions

virtual af::array PosteriorGradientLatents (const af::array &dmx, const af::array &dvx)
 Posterior gradient of latent inputs /f$\mathbf{X}/f$. More...
 
virtual void UpdateParametersInternal ()
 Updates the parameters. More...
 
- Protected Member Functions inherited from NeuralEngine::MachineLearning::IModel< Scalar >
 IModel (int numData, int numDimension, ModelType type)
 Constructor. More...
 

Protected Attributes

int iq
 latent dimension More...
 
int iDControlEmiss
 
int iDControlDyn
 
Scalar dSn
 
bool bGPemission
 
bool bControlToEmiss
 
Scalar dPriorMean
 prior mean More...
 
Scalar dPriorVariance
 prior variance More...
 
Scalar dPriorX1
 prior /f$x_1/f$ More...
 
Scalar dPriorX2
 prior /f$x_2/f$ More...
 
af::array afFactorX1
 natural parameter factor 1 for latent variable More...
 
af::array afFactorX2
 natural parameter factor 2 for latent variable More...
 
af::array afPosteriorX1
 posterior natural parameter 1 for latent variable More...
 
af::array afPosteriorX2
 posterior natural parameter 2 for latent variable More...
 
af::array afXControl
 
af::array afDynIndexes
 
af::array afPriorX1
 prior /f$x_1/f$ More...
 
af::array afPriorX2
 prior /f$x_2/f$ More...
 
af::array afPriorX1Cav
 prior /f$x_1/f$ More...
 
af::array afPriorX2Cav
 prior /f$x_2/f$ More...
 
af::array afPriorMean
 prior mean for hierarchy mode More...
 
af::array afPriorVariance
 prior variance for hierarchy mode More...
 
af::array afPriorMeanCav
 prior mean for hierarchy mode More...
 
af::array afPriorVarianceCav
 prior variance for hierarchy mode More...
 
af::array afGradMean
 prior mean gradient for hiersrchy mode More...
 
af::array afGradVariance
 prior variance gradient for hiersrchy mode More...
 
af::array afGradMeanCav
 prior mean gradient for hiersrchy mode More...
 
af::array afGradVarianceCav
 prior variance gradient for hiersrchy mode More...
 
af::array afLatentGradientX
 top down gradient More...
 
XInit eEmMethod
 
PropagationMode pMode
 
- Protected Attributes inherited from NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >
bool bInit
 check if model is initialized More...
 
af::array afY
 training dataset, mean substracted More...
 
af::array afBias
 the bias More...
 
af::array afSegments
 Index of starting positions for all trials. More...
 
LikelihoodBaseLayer< Scalar > * likLayer
 liklihood layer More...
 
- Protected Attributes inherited from NeuralEngine::MachineLearning::IModel< Scalar >
ModelType mType
 
int iN
 dataset length More...
 
int iD
 dataset dimension More...
 
int iBatchSize
 size of the batch More...
 
af::array afIndexes
 indexes of /f$\mathbf{X}/f$ for batch learning More...
 
af::dtype m_dType
 floating point precision flag for af::array More...
 
- Protected Attributes inherited from NeuralEngine::MachineLearning::GPNode< Scalar >
std::vector< std::shared_ptr< GPNode< Scalar > > > mChild
 
GPNode< Scalar > * mParent
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, unsigned int version)
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename Scalar>
class NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >


Base class with abstract and basic function definitions. All GP state space models will be derived from this class.

HmetalT, 26.10.2017.

Definition at line 31 of file FgGPStateSpaceBaseModel.h.

Constructor & Destructor Documentation

◆ GPSSBaseModel() [1/2]

template<typename Scalar >
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::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.

Hmetal T, 04/05/2020.

Parameters
YObservation data.
latentDimensionThe latent dimension.
priorMean(Optional) The prior mean.
priorVariance(Optional) The prior variance.
numInducing(Optional) Number of inducings inputs.
lType(Optional) The likelihood type.
GPemission(Optional) True to non-linear emission function.
emethod(Optional) The embed method.

◆ GPSSBaseModel() [2/2]

template<typename Scalar >
NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::GPSSBaseModel ( )

Default constructor.

Hmetal T, 09/05/2022.

◆ ~GPSSBaseModel()

Destructor.

HmetalT, 05/05/2020.

Member Function Documentation

◆ Optimise()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::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 
)
overridevirtual

Optimizes the model parameters for best fit.

Hmetal T, 29.11.2017.

Parameters
method(Optional) the optimization method.
tol(Optional) the tolerance.
reinit_hypers(Optional) true to re hypers.
maxiter(Optional) max iterations.
mb_size(Optional) batch size.
LSType(Optional) linesearch type.
disp(Optional) true to disp.

Reimplemented from NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >.

◆ Init()

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::Init ( af::array &  mx)
virtual

Initializes the model.

Hmetal T, 29.11.2017.

Returns
true if it succeeds, false if it fails.

◆ PosteriorLatents()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::PosteriorLatents ( af::array &  mx,
af::array &  vx 
)
virtual

Get posterior distribution of latent variables /f$\mathbf{X}/f$.

Hmetal T, 09/12/2019.

Parameters
indexIndex of selected inputs.
mx[in,out] The mean.
vx[in,out] The variance.

◆ GetNumParameters()

template<typename Scalar >
virtual int NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::GetNumParameters ( )
overridevirtual

◆ SetParameters()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::SetParameters ( const af::array &  param)
overridevirtual

Sets the parameters for each optimization iteration.

, 26.06.2018.

Parameters
paramThe parameter.

Reimplemented from NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >.

Reimplemented in NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel< Scalar >, and NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel< Scalar >.

◆ GetParameters()

template<typename Scalar >
virtual af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::GetParameters ( )
overridevirtual

Gets the parameters for each optimization iteration.

, 26.06.2018.

Parameters
paramThe parameter.

Reimplemented from NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >.

Reimplemented in NeuralEngine::MachineLearning::GPModels::SparseDeepGPSSMBaseModel< Scalar >, and NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel< Scalar >.

◆ UpdateDynamicIndexes()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::UpdateDynamicIndexes ( )

Updates the dynamic indexes.

Hmetal T, 18/05/2022.

◆ PosteriorGradientLatents()

template<typename Scalar >
virtual af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::PosteriorGradientLatents ( const af::array &  dmx,
const af::array &  dvx 
)
protectedvirtual

Posterior gradient of latent inputs /f$\mathbf{X}/f$.

Hmetal T, 09/12/2019.

Parameters
dmx[in,out] The gradient of the mean.
dvx[in,out] The the gradient of the variance.

◆ UpdateParametersInternal()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::UpdateParametersInternal ( )
protectedvirtual

Updates the parameters.

, 26.06.2018.

◆ serialize()

template<typename Scalar >
template<class Archive >
void NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::serialize ( Archive &  ar,
unsigned int  version 
)
inlineprivate

Definition at line 212 of file FgGPStateSpaceBaseModel.h.

Friends And Related Function Documentation

◆ boost::serialization::access

template<typename Scalar >
friend class boost::serialization::access
friend

Definition at line 209 of file FgGPStateSpaceBaseModel.h.

Member Data Documentation

◆ iq

latent dimension

Definition at line 166 of file FgGPStateSpaceBaseModel.h.

◆ iDControlEmiss

template<typename Scalar >
int NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::iDControlEmiss
protected

Definition at line 167 of file FgGPStateSpaceBaseModel.h.

◆ iDControlDyn

template<typename Scalar >
int NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::iDControlDyn
protected

Definition at line 168 of file FgGPStateSpaceBaseModel.h.

◆ dSn

Definition at line 170 of file FgGPStateSpaceBaseModel.h.

◆ bGPemission

template<typename Scalar >
bool NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::bGPemission
protected

Definition at line 172 of file FgGPStateSpaceBaseModel.h.

◆ bControlToEmiss

template<typename Scalar >
bool NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::bControlToEmiss
protected

Definition at line 173 of file FgGPStateSpaceBaseModel.h.

◆ dPriorMean

template<typename Scalar >
Scalar NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::dPriorMean
protected

prior mean

Definition at line 175 of file FgGPStateSpaceBaseModel.h.

◆ dPriorVariance

template<typename Scalar >
Scalar NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::dPriorVariance
protected

prior variance

Definition at line 176 of file FgGPStateSpaceBaseModel.h.

◆ dPriorX1

template<typename Scalar >
Scalar NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::dPriorX1
protected

prior /f$x_1/f$

Definition at line 177 of file FgGPStateSpaceBaseModel.h.

◆ dPriorX2

template<typename Scalar >
Scalar NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::dPriorX2
protected

prior /f$x_2/f$

Definition at line 178 of file FgGPStateSpaceBaseModel.h.

◆ afFactorX1

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afFactorX1
protected

natural parameter factor 1 for latent variable

Definition at line 180 of file FgGPStateSpaceBaseModel.h.

◆ afFactorX2

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afFactorX2
protected

natural parameter factor 2 for latent variable

Definition at line 181 of file FgGPStateSpaceBaseModel.h.

◆ afPosteriorX1

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPosteriorX1
protected

posterior natural parameter 1 for latent variable

Definition at line 182 of file FgGPStateSpaceBaseModel.h.

◆ afPosteriorX2

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPosteriorX2
protected

posterior natural parameter 2 for latent variable

Definition at line 183 of file FgGPStateSpaceBaseModel.h.

◆ afXControl

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afXControl
protected

Definition at line 184 of file FgGPStateSpaceBaseModel.h.

◆ afDynIndexes

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afDynIndexes
protected

Definition at line 185 of file FgGPStateSpaceBaseModel.h.

◆ afPriorX1

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorX1
protected

prior /f$x_1/f$

Definition at line 187 of file FgGPStateSpaceBaseModel.h.

◆ afPriorX2

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorX2
protected

prior /f$x_2/f$

Definition at line 188 of file FgGPStateSpaceBaseModel.h.

◆ afPriorX1Cav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorX1Cav
protected

prior /f$x_1/f$

Definition at line 189 of file FgGPStateSpaceBaseModel.h.

◆ afPriorX2Cav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorX2Cav
protected

prior /f$x_2/f$

Definition at line 190 of file FgGPStateSpaceBaseModel.h.

◆ afPriorMean

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorMean
protected

prior mean for hierarchy mode

Definition at line 191 of file FgGPStateSpaceBaseModel.h.

◆ afPriorVariance

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorVariance
protected

prior variance for hierarchy mode

Definition at line 192 of file FgGPStateSpaceBaseModel.h.

◆ afPriorMeanCav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorMeanCav
protected

prior mean for hierarchy mode

Definition at line 193 of file FgGPStateSpaceBaseModel.h.

◆ afPriorVarianceCav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afPriorVarianceCav
protected

prior variance for hierarchy mode

Definition at line 194 of file FgGPStateSpaceBaseModel.h.

◆ afGradMean

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afGradMean
protected

prior mean gradient for hiersrchy mode

Definition at line 195 of file FgGPStateSpaceBaseModel.h.

◆ afGradVariance

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afGradVariance
protected

prior variance gradient for hiersrchy mode

Definition at line 196 of file FgGPStateSpaceBaseModel.h.

◆ afGradMeanCav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afGradMeanCav
protected

prior mean gradient for hiersrchy mode

Definition at line 197 of file FgGPStateSpaceBaseModel.h.

◆ afGradVarianceCav

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afGradVarianceCav
protected

prior variance gradient for hiersrchy mode

Definition at line 198 of file FgGPStateSpaceBaseModel.h.

◆ afLatentGradientX

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::afLatentGradientX
protected

top down gradient

Definition at line 200 of file FgGPStateSpaceBaseModel.h.

◆ eEmMethod

template<typename Scalar >
XInit NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::eEmMethod
protected

Definition at line 205 of file FgGPStateSpaceBaseModel.h.

◆ pMode

template<typename Scalar >
PropagationMode NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >::pMode
protected

Definition at line 207 of file FgGPStateSpaceBaseModel.h.


The documentation for this class was generated from the following file: