13#include <MachineLearning/FgGPNode.h>
14#include <MachineLearning/FgGPBaseModel.h>
15#include <MachineLearning/FgBackconstraints.h>
16#include <boost/serialization/map.hpp>
20 namespace MachineLearning
31 template<
typename Scalar>
250 void InitFactors(
const af::array& expandedX1,
const af::array& expandedX2);
253 af::array afStyleIdx;
254 af::array afStyleInducingIdx;
256 af::array afInducingStyle;
257 af::array afFactorX1;
258 af::array afFactorX2;
259 af::array afPosteriorX1;
260 af::array afPosteriorX2;
261 std::map<std::string, int> mSubStyles;
268 friend class boost::serialization::access;
270 template<
class Archive>
271 void serialize(Archive& ar,
unsigned int version)
275 ar& BOOST_SERIALIZATION_NVP(afStyleIdx);
276 ar& BOOST_SERIALIZATION_NVP(afStyleInducingIdx);
277 ar& BOOST_SERIALIZATION_NVP(afStyle);
278 ar& BOOST_SERIALIZATION_NVP(afInducingStyle);
279 ar& BOOST_SERIALIZATION_NVP(mSubStyles);
280 ar& BOOST_SERIALIZATION_NVP(sName);
281 ar& BOOST_SERIALIZATION_NVP(m_dType);
293 template<
typename Scalar>
312 LogLikType lType = LogLikType::Gaussian, XInit emethod = XInit::pca);
342 OptimizerType method = L_BFGS,
344 bool reinit_hypers =
true,
347 LineSearchType lsType = MoreThuente,
359 virtual bool Init(af::array& mx);
433 void FixLatents(
bool isFixed);
461 void SetPrior(
const af::array mean,
const af::array var);
605 std::map<std::string, Style<Scalar>>*
mStyles;
610 friend class boost::serialization::access;
614 template<
class Archive>
615 void serialize(Archive& ar,
unsigned int version)
617 ar& boost::serialization::base_object<GPBaseModel<Scalar>>(*this);
618 ar& boost::serialization::base_object<GPNode<Scalar>>(*this);
626 ar& BOOST_SERIALIZATION_NVP(iq);
627 ar& BOOST_SERIALIZATION_NVP(dPriorMean);
628 ar& BOOST_SERIALIZATION_NVP(dPriorVariance);
629 ar& BOOST_SERIALIZATION_NVP(afFactorX1);
630 ar& BOOST_SERIALIZATION_NVP(afFactorX2);
631 ar& BOOST_SERIALIZATION_NVP(eEmMethod);
632 ar& BOOST_SERIALIZATION_NVP(afPriorMean);
633 ar& BOOST_SERIALIZATION_NVP(afPriorVariance);
634 ar& BOOST_SERIALIZATION_NVP(afPriorMeanCav);
635 ar& BOOST_SERIALIZATION_NVP(afPriorVarianceCav);
636 ar& BOOST_SERIALIZATION_NVP(afPriorX1);
637 ar& BOOST_SERIALIZATION_NVP(afPriorX2);
638 ar& BOOST_SERIALIZATION_NVP(backConst);
639 ar& BOOST_SERIALIZATION_NVP(mStyles);
640 ar& BOOST_SERIALIZATION_NVP(bIsLatetsFixed);
Base class with abstract and basic function definitions. All GP models will be derived from this clas...
Base class with abstract and basic function definitions. All deep GP models will be derived from this...
af::array afPriorVariance
prior variance for hiersrchy mode
af::array afGradVarianceCav
prior variance gradient for hiersrchy mode
virtual void UpdateParameters() override
Updates the parameters.
virtual void FixInducing(bool isfixed)
Set fixation for inducing inputs.
void SetPrior(const af::array mean, const af::array var)
Sets the prior.
Scalar dPriorX1
prior /f$x_1/f$
Scalar dPriorVariance
prior variance
virtual void UpdateParametersInternal()
Updates the internal parameters.
std::map< std::string, Style< Scalar > > * GetStyles()
Gets the styles.
virtual void SetParameters(const af::array ¶m) override
Sets the parameters for each optimization iteration.
GPLVMBaseModel()
Default constructor.
af::array afPriorMeanCav
prior mean for hiersrchy mode
af::array afFactorX1
natural parameter factor 1 for latent variable
int GetLatentDimension()
Gets latent dimension.
af::array afLatentGradientX
top down gradient
std::map< std::string, Style< Scalar > > * mStyles
style variable
virtual bool Init() override
Initializes the model.
virtual int GetNumParameters() override
Gets number of parameters.
void SetStyles(std::map< std::string, Style< Scalar > > *styles)
Sets the syles.
virtual ~GPLVMBaseModel()
Destructor.
af::array afGradMean
prior mean gradient for hiersrchy mode
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.
af::array afPriorX2Cav
prior /f$x_2/f$
virtual void FixKernelParameters(bool isfixed)
Sets fixation for hyperparameters.
void SetLatentGradient(const af::array &dmParent, const af::array &dvParent)
Sets latent gradient.
void SetLatentGradientCavity(const af::array &dmParent, const af::array &dvParent)
Sets the latent cavity gradient.
virtual bool Init(af::array &mx)
Initializes the model.
af::array afPosteriorX1
posterior natural parameter 1 for latent variable
af::array afGradMeanCav
prior mean gradient for hiersrchy mode
af::array afFactorX2
natural parameter factor 2 for latent variable
void SetPriorCavity(const af::array meanCav, const af::array varCav)
Sets the cavity prior.
af::array afPriorVarianceCav
prior variance for hiersrchy mode
IBackconstraint< Scalar > * backConst
back-constraint
af::array afPriorX1
prior /f$x_1/f$
af::array GetMeanGradient()
Gets prior mean gradient.
void AddStyle(Style< Scalar > style)
Adds a style.
GPLVMBaseModel(const af::array &Y, int latentDimension, Scalar priorMean=0.0, Scalar priorVariance=1.0, LogLikType lType=LogLikType::Gaussian, XInit emethod=XInit::pca)
Constructor.
af::array GetVarGradient()
Gets prior variance gradient.
af::array afPriorMean
prior mean for hiersrchy mode
af::array afGradVariance
prior variance gradient for hiersrchy mode
Scalar dPriorMean
prior mean
virtual void PosteriorLatents(af::array &mx, af::array &vx)
Get posterior distribution of latent variables /f$\mathbf{X}/f$.
af::array afPosteriorX2
posterior natural parameter 2 for latent variable
af::array afPriorX2
prior /f$x_2/f$
af::array afPriorX1Cav
prior /f$x_1/f$
virtual af::array PosteriorGradientLatents(const af::array &dmx, const af::array &dvx)
Posterior gradient of latent inputs /f$\mathbf{X}/f$.
virtual af::array LatentGradient(const af::array &dm, const af::array &dv)
Latent gradient.
virtual af::array GetParameters() override
Gets the parameters for each optimization iteration.
void SetBackConstraint(IBackconstraint< Scalar > *constraint)
Sets a back-constraint.
IBackconstraint< Scalar > * GetBackConstraint()
Gets the back-constraint.
Scalar dPriorX2
prior /f$x_2/f$
Abstract class for back-constraints, a kind of prior knowledge to force topological positions of unce...
Back-constraints via kernel based regression.
Back-constraints via Periodic topological constraint.
virtual int GetNumInducingSubstyles()
Gets number of inducing sub-styles.
af::array GetGradientCollapsed(const af::array &factorGradient)
Gets gradient collapsed.
virtual ~Style()
Destructor.
void UpdatePosterior(const af::array &postX1, const af::array &postX2)
Updates the parameters.
void SetParameters(const af::array ¶m)
Sets the parameters.
int GetNumInducingParameters()
Gets number of inducing parameters.
const af::array GetStyleIndex()
Gets style index.
void InitFactors(const af::array &expandedX1, const af::array &expandedX2)
Initializes the factors.
virtual int GetNumSubstyles()
Gets number of sub-styles.
af::array GetParameters()
Gets the parameters.
void GetFactorsExpanded(af::array &X1, af::array &X2)
Gets factor x coordinate 1.
af::array GetInducingGradientCollapsed(const af::array &styleGradient)
Gets style inducing gradient collapsed.
virtual void AddSubstyle(std::string name, int numFrames)
Adds a sub-style.
af::array GetInducingParameters()
Gets inducing parameters.
af::array GetStyleExpanded()
Gets style variable expanded to match associated /f$\matchbf{x}$/f.
std::string GetName()
Gets the name of the style.
int GetNumParameters()
Gets number parameters.
af::array GetStyle()
Gets the style variable.
Style()
Default constructor.
std::map< std::string, int > GetSubstyles()
Gets the sub-styles.
void SetInducingParameters(const af::array ¶m)
Sets inducing parameters.
af::dtype m_dType
floating point precision flag for af::array
af::array GetInducingStyleExpanded()
Gets inducing style expanded.
void SetInducingStyleIndex(const af::array &indx)
Sets inducing style index.
Style(std::string name)
Default constructor.
This class represents grouping nodes in a hiearchy.