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

Base class for all sparse GPLVM models. More...

#include <FgSparseGPLVMBaseModel.h>

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

Public Member Functions

 SparseGPLVMBaseModel (const af::array &Y, int latentDimension, Scalar priorMean=0.0, Scalar priorVariance=1.0, int numInducing=200, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
 Constructor. More...
 
 SparseGPLVMBaseModel ()
 Default constructor. More...
 
virtual ~SparseGPLVMBaseModel ()
 Destructor. More...
 
virtual void PredictF (const af::array &testInputs, af::array &mf, af::array &vf) override
 Predict noise free functions values \(\mathbf{F}_*\). More...
 
virtual void SampleY (const af::array inputs, int numSamples, af::array &outFunctions) override
 Generate function samples from posterior. More...
 
virtual bool Init () override
 Initializes the model. 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...
 
virtual void UpdateParameters () override
 Updates the parameters. More...
 
virtual void FixKernelParameters (bool isfixed) override
 Sets fixation for hyperparameters. More...
 
virtual void FixInducing (bool isfixed) override
 Set fixation for inducing inputs. More...
 
- Public Member Functions inherited from NeuralEngine::MachineLearning::GPModels::GPLVMBaseModel< Scalar >
 GPLVMBaseModel (const af::array &Y, int latentDimension, Scalar priorMean=0.0, Scalar priorVariance=1.0, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
 Constructor. More...
 
 GPLVMBaseModel ()
 Default constructor. More...
 
virtual ~GPLVMBaseModel ()
 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 bool Init () override
 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...
 
virtual void UpdateParameters () override
 Updates the parameters. More...
 
virtual void FixKernelParameters (bool isfixed)
 Sets fixation for hyperparameters. More...
 
virtual void FixInducing (bool isfixed)
 Set fixation for inducing inputs. More...
 
void FixLatents (bool isFixed)
 
af::array GetMeanGradient ()
 Gets prior mean gradient. More...
 
af::array GetVarGradient ()
 Gets prior variance gradient. More...
 
void SetPrior (const af::array mean, const af::array var)
 Sets the prior. More...
 
void SetPriorCavity (const af::array meanCav, const af::array varCav)
 Sets the cavity prior. More...
 
void SetLatentGradient (const af::array &dmParent, const af::array &dvParent)
 Sets latent gradient. More...
 
void SetLatentGradientCavity (const af::array &dmParent, const af::array &dvParent)
 Sets the latent cavity gradient. More...
 
int GetLatentDimension ()
 Gets latent dimension. More...
 
void SetBackConstraint (IBackconstraint< Scalar > *constraint)
 Sets a back-constraint. More...
 
IBackconstraint< Scalar > * GetBackConstraint ()
 Gets the back-constraint. More...
 
void SetStyles (std::map< std::string, Style< Scalar > > *styles)
 Sets the syles. More...
 
void AddStyle (Style< Scalar > style)
 Adds a style. More...
 
std::map< std::string, Style< Scalar > > * GetStyles ()
 Gets the styles. More...
 
- 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 Attributes

int ik
 number of inducing inputs More...
 
SparseGPBaseLayer< Scalar > * gpLayer
 sparse Gaussian Process layer More...
 
- Protected Attributes inherited from NeuralEngine::MachineLearning::GPModels::GPLVMBaseModel< Scalar >
int iq
 latent dimension More...
 
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 afPriorMean
 prior mean for hiersrchy mode More...
 
af::array afPriorVariance
 prior variance for hiersrchy mode More...
 
af::array afPriorMeanCav
 prior mean for hiersrchy mode More...
 
af::array afPriorVarianceCav
 prior variance for hiersrchy mode More...
 
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 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
 
IBackconstraint< Scalar > * backConst
 back-constraint More...
 
std::map< std::string, Style< Scalar > > * mStyles
 style variable More...
 
bool bIsLatetsFixed
 
- 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 AEP::SGPLayer< Scalar >
 
class PowerEP::SGPLayer< Scalar >
 
class boost::serialization::access
 

Additional Inherited Members

- Protected Member Functions inherited from NeuralEngine::MachineLearning::GPModels::GPLVMBaseModel< Scalar >
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 internal parameters. More...
 
virtual af::array LatentGradient (const af::array &dm, const af::array &dv)
 Latent gradient. More...
 
- Protected Member Functions inherited from NeuralEngine::MachineLearning::IModel< Scalar >
 IModel (int numData, int numDimension, ModelType type)
 Constructor. More...
 

Detailed Description

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

Base class for all sparse GPLVM models.


GPLVM are the nonlinear dual version of probabilistic PCA, where a low dimensional latent variable \(\mathbf{X}=[\mathbf{x}_1,...,\mathbf{x}_N]^T\) is mapped onto a high dimensional data variable \(\mathbf{Y}=[\mathbf{y}_1,...,\mathbf{y}_N]^T\) via prior mapping function \(f(\mathbf{x})\). The difference to normal GPs is the uncertainty of \(\mathbf{X}\), which will be initialized via PCA and optimized during learning. To avoid memory issues for larger data sets, the algorithm takes use of sparse approximation techniques.

Sparse approximations are used for larger data sets to reduce memory size and computational complexity. This is done by introducing a subset of inducing points or pseudo inputs to approximate the full set. The inversion of the kernel matrix depends only on those points and reduces the computational complexity from \(O(N^3)\) to \(O(k^2N)\), where \(k\) is the number of inducing points and \(N\) the length of the data set.

References:

, 24.11.2019.

Definition at line 78 of file FgSparseGPLVMBaseModel.h.

Constructor & Destructor Documentation

◆ SparseGPLVMBaseModel() [1/2]

template<typename Scalar >
NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::SparseGPLVMBaseModel ( const af::array &  Y,
int  latentDimension,
Scalar  priorMean = 0.0,
Scalar  priorVariance = 1.0,
int  numInducing = 200,
LogLikType  lType = LogLikType::Gaussian,
XInit  emethod = XInit::pca 
)

Constructor.

, 21.03.2018.

Parameters
YThe training data.
latentDimensionThe latent dimension.
priorMean(Optional) The prior mean.
priorVariance(Optional) The prior variance.
numInducing(Optional) Number of inducing points.
lType(Optional) The likelihood or objective type.
emethod(Optional) The initialisation method of the latent variable.

◆ SparseGPLVMBaseModel() [2/2]

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

Default constructor.

, 26.03.2018.

◆ ~SparseGPLVMBaseModel()

Destructor.

, 15.05.2018.

Member Function Documentation

◆ PredictF()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::PredictF ( const af::array &  testInputs,
af::array &  mf,
af::array &  vf 
)
overridevirtual

Predict noise free functions values \(\mathbf{F}_*\).

Hmetal T, 05/05/2020.

Parameters
testInputsThe test inputs.
mf[in,out] mean of function values.
vf[in,out] The variance of function values.

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

◆ SampleY()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::SampleY ( const af::array  inputs,
int  numSamples,
af::array &  outFunctions 
)
overridevirtual

Generate function samples from posterior.

Hmetal T, 18/06/2019.

Parameters
outFunctions[in,out] The out functions.
inputsThe inputs.
numSamplesNumber of samples.

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

◆ Init()

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::Init ( )
overridevirtual

Initializes the model.

Hmetal T, 29.11.2017.

Returns
true if it succeeds, false if it fails.

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

◆ GetNumParameters()

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

Gets number of parameters.

, 26.06.2018.

Returns
The number parameters.

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

◆ SetParameters()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< 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::GPLVMBaseModel< Scalar >.

◆ GetParameters()

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

Gets the parameters for each optimization iteration.

, 26.06.2018.

Parameters
paramThe parameter.

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

◆ UpdateParameters()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::UpdateParameters ( )
overridevirtual

Updates the parameters.

, 26.06.2018.

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

◆ FixKernelParameters()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::FixKernelParameters ( bool  isfixed)
overridevirtual

Sets fixation for hyperparameters.

Hmetal T, 16/12/2019.

Parameters
isfixedTrue if isfixed.

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

◆ FixInducing()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >::FixInducing ( bool  isfixed)
overridevirtual

Set fixation for inducing inputs.

Hmetal T, 16/12/2019.

Parameters
isfixedTrue if isfixed.

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

◆ serialize()

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

Definition at line 208 of file FgSparseGPLVMBaseModel.h.

Friends And Related Function Documentation

◆ AEP::SGPLayer< Scalar >

template<typename Scalar >
friend class AEP::SGPLayer< Scalar >
friend

Definition at line 198 of file FgSparseGPLVMBaseModel.h.

◆ PowerEP::SGPLayer< Scalar >

template<typename Scalar >
friend class PowerEP::SGPLayer< Scalar >
friend

Definition at line 198 of file FgSparseGPLVMBaseModel.h.

◆ boost::serialization::access

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

Definition at line 205 of file FgSparseGPLVMBaseModel.h.

Member Data Documentation

◆ ik

number of inducing inputs

Definition at line 197 of file FgSparseGPLVMBaseModel.h.

◆ gpLayer

sparse Gaussian Process layer

Definition at line 198 of file FgSparseGPLVMBaseModel.h.


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