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


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

#include <FgGPBaseModel.h>

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

Public Member Functions

 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

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 boost::serialization::access
 
class GaussLikLayer< Scalar >
 
class ProbitLikLayer< Scalar >
 

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::GPBaseModel< Scalar >


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

HmetalT, 26.10.2017.

Definition at line 39 of file FgGPBaseModel.h.

Constructor & Destructor Documentation

◆ GPBaseModel() [1/2]

template<typename Scalar >
NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::GPBaseModel ( const af::array &  Y,
LogLikType  lType = LogLikType::Gaussian,
ModelType  mtype = ModelType::GPR 
)

Constructor.

, 26.03.2018.

Parameters
YThe data af::array to process.

◆ GPBaseModel() [2/2]

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

Default Constructor.

Hmetal T, 29.11.2017.

◆ ~GPBaseModel()

template<typename Scalar >
virtual NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::~GPBaseModel ( )
virtual

Destructor.

, 23.04.2018.

Member Function Documentation

◆ Optimise()

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

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 in NeuralEngine::MachineLearning::GPModels::GPLVMBaseModel< Scalar >, and NeuralEngine::MachineLearning::GPModels::GPSSBaseModel< Scalar >.

◆ Init()

◆ PredictF()

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

◆ PredictY()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::PredictY ( const af::array &  testInputs,
af::array &  my,
af::array &  vy 
)
virtual

Prediction of test outputs \(\mathbf{Y}_*\).

, 12.06.2018.

Parameters
my[in,out] The posterior mean function.
vy[in,out] The posterior covariance function.
testX[in,out] The test inputs.

Reimplemented in NeuralEngine::MachineLearning::GPModels::SparseGPSSMBaseModel< Scalar >.

◆ SampleY()

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

Generate function samples from posterior.

Hmetal T, 18/06/2019.

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

Reimplemented in NeuralEngine::MachineLearning::GPModels::DeepGPBaseModel< Scalar >, NeuralEngine::MachineLearning::GPModels::SparseDeepGPLVMBaseModel< Scalar >, NeuralEngine::MachineLearning::GPModels::SparseGPBaseModel< Scalar >, and NeuralEngine::MachineLearning::GPModels::SparseGPLVMBaseModel< Scalar >.

◆ AddData()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::AddData ( const af::array  Ytrain)
virtual

Adds training data to the model.

Hmetal T, 29.11.2017.

Parameters
Ytrain[in,out] The training data.

◆ GetTrainingData()

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::GetTrainingData ( )

Gets the training data set Y.

, 26.03.2018.

Returns
The training data.

◆ SetTrainingData()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::SetTrainingData ( af::array &  data)

Sets training data Y.

, 27.03.2018.

Parameters
data[in,out] The data.

◆ GetNumParameters()

◆ SetParameters()

◆ GetParameters()

◆ UpdateParameters()

◆ FixLikelihoodParameters()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::FixLikelihoodParameters ( bool  isfixed)
virtual

Sets the likelihood parameters to be fixed or not for optimization.

Hmetal T, 17/12/2019.

Parameters
isfixedTrue if is fixed.

◆ SetSegments()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::SetSegments ( af::array  segments)

Sets fixation for hyperparameters.

Hmetal T, 16/12/2019.

Parameters
isfixedTrue if isfixed.

Sets the start indexes array of each sequence.

Hmetal T, 18/07/2022.

Parameters
segmentsThe segments.

◆ GetSegments()

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::GetSegments ( )

Gets the start index array for the sequences.

Hmetal T, 18/07/2022.

Returns
The segments.

◆ serialize()

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

Definition at line 252 of file FgGPBaseModel.h.

Friends And Related Function Documentation

◆ boost::serialization::access

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

Definition at line 246 of file FgGPBaseModel.h.

◆ GaussLikLayer< Scalar >

template<typename Scalar >
friend class GaussLikLayer< Scalar >
friend

Definition at line 246 of file FgGPBaseModel.h.

◆ ProbitLikLayer< Scalar >

template<typename Scalar >
friend class ProbitLikLayer< Scalar >
friend

Definition at line 246 of file FgGPBaseModel.h.

Member Data Documentation

◆ bInit

template<typename Scalar >
bool NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::bInit
protected

check if model is initialized

Definition at line 233 of file FgGPBaseModel.h.

◆ afY

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::afY
protected

training dataset, mean substracted

Definition at line 234 of file FgGPBaseModel.h.

◆ afBias

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::afBias
protected

the bias

Definition at line 235 of file FgGPBaseModel.h.

◆ afSegments

template<typename Scalar >
af::array NeuralEngine::MachineLearning::GPModels::GPBaseModel< Scalar >::afSegments
protected

Index of starting positions for all trials.

Definition at line 236 of file FgGPBaseModel.h.

◆ likLayer

liklihood layer

Definition at line 239 of file FgGPBaseModel.h.


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