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

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

#include <FgSparseGPBaseModel.h>

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

Public Member Functions

 SparseGPBaseModel (const af::array &Y, const af::array &X, int numInducing=200, LogLikType lType=LogLikType::Gaussian)
 Constructor. More...
 
 SparseGPBaseModel ()
 Default constructor. More...
 
virtual ~SparseGPBaseModel ()
 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...
 
af::array GetTrainingInputs ()
 Gets training inputs X. More...
 
void SetTrainingInputs (af::array &inputs)
 Gets training inputs X. More...
 
af::array GetPseudoInputs ()
 Gets pseudo inputs. 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)
 Sets fixation for hyperparameters. More...
 
virtual void FixInducing (bool isfixed)
 Set fixation for inducing inputs. More...
 
SparseGPBaseLayer< Scalar > * GetGPLayer ()
 Gets the gp layer. 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...
 

Protected Attributes

int ik
 number of inducing inputs More...
 
int iq
 latent dimension More...
 
af::array afX
 training inputs More...
 
SparseGPBaseLayer< Scalar > * gpLayer
 gp layer More...
 
- 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...
 

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::IModel< Scalar >
 IModel (int numData, int numDimension, ModelType type)
 Constructor. More...
 

Detailed Description

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

Base class for all sparse GP models.


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 computationsl 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.

For more information see: , 21.03.2018.

Definition at line 58 of file FgSparseGPBaseModel.h.

Constructor & Destructor Documentation

◆ SparseGPBaseModel() [1/2]

template<typename Scalar >
NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >::SparseGPBaseModel ( const af::array &  Y,
const af::array &  X,
int  numInducing = 200,
LogLikType  lType = LogLikType::Gaussian 
)

Constructor.

, 21.03.2018.

Parameters
X[in,out] The training inputs.
Y[in,out] The training data.
numInducingNumber of inducings points.
lTypeThe likelihood or objective type.

◆ SparseGPBaseModel() [2/2]

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

Default constructor.

, 26.03.2018.

◆ ~SparseGPBaseModel()

Destructor.

, 15.05.2018.

Member Function Documentation

◆ PredictF()

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

◆ GetTrainingInputs()

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >::GetTrainingInputs ( )

Gets training inputs X.

, 27.03.2018.

Returns
The training inputs.

◆ SetTrainingInputs()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >::SetTrainingInputs ( af::array &  inputs)

Gets training inputs X.

, 27.03.2018.

Parameters
inputs[in,out] The inputs.

◆ GetPseudoInputs()

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >::GetPseudoInputs ( )

Gets pseudo inputs.

Hmetal T, 17/06/2019.

Returns
The pseudo inputs.

◆ Init()

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< 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::GPBaseModel< Scalar >.

◆ GetNumParameters()

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

Gets number of parameters.

, 26.06.2018.

Returns
The number parameters.

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

◆ SetParameters()

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

◆ GetParameters()

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

Gets the parameters for each optimization iteration.

, 26.06.2018.

Parameters
paramThe parameter.

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

◆ UpdateParameters()

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

Updates the parameters.

Hmetal T, 23/03/2020.

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

◆ FixKernelParameters()

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

Sets fixation for hyperparameters.

Hmetal T, 16/12/2019.

Parameters
isfixedTrue if isfixed.

◆ FixInducing()

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

Set fixation for inducing inputs.

Hmetal T, 16/12/2019.

Parameters
isfixedTrue if isfixed.

◆ GetGPLayer()

Gets the gp layer.

Hmetal T, 18/12/2019.

Returns
Null if it fails, else the gp layer.

◆ serialize()

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

Definition at line 222 of file FgSparseGPBaseModel.h.

Friends And Related Function Documentation

◆ AEP::SGPLayer< Scalar >

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

Definition at line 212 of file FgSparseGPBaseModel.h.

◆ PowerEP::SGPLayer< Scalar >

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

Definition at line 212 of file FgSparseGPBaseModel.h.

◆ boost::serialization::access

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

Definition at line 219 of file FgSparseGPBaseModel.h.

Member Data Documentation

◆ ik

number of inducing inputs

Definition at line 208 of file FgSparseGPBaseModel.h.

◆ iq

latent dimension

Definition at line 209 of file FgSparseGPBaseModel.h.

◆ afX

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >::afX
protected

training inputs

Definition at line 210 of file FgSparseGPBaseModel.h.

◆ gpLayer

gp layer

Definition at line 212 of file FgSparseGPBaseModel.h.


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