NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
FgILayer.h
1
11#pragma once
12
13#undef min
14#undef max
15
16#include <NeMachineLearningLib.h>
17#include <MachineLearning/CommonUtil.h>
18
19
20namespace NeuralEngine
21{
22 namespace MachineLearning
23 {
24 enum class LayerType
25 {
26 LogLik,
27 GP,
28 Emission // emission layer for SSM
29 };
30
36 template<typename Scalar>
37 class NE_IMPEXP ILayer
38 {
39 public:
40
50 ILayer(LayerType type, int numPoints, int outputDim)
51 : lType(type), iN(numPoints), iD(outputDim), m_dType(CommonUtil<Scalar>::CheckDType()) { }
52
58 virtual ~ILayer() = default;
59
67 LayerType GetType() { return lType; }
68
76 virtual int GetNumParameters() = 0;
77
85 virtual void SetParameters(const af::array& param) = 0;
86
94 virtual af::array GetParameters() = 0;
95
101 virtual void UpdateParameters() = 0;
102
111 virtual void SetDataSize(int length, int dimension)
112 {
113 iN = length;
114 iD = dimension;
115 }
116
117 protected:
118
124 ILayer() { }
125
126 int iD;
127 int iN;
128
129 LayerType lType;
130
131 af::dtype m_dType;
132
133 private:
134 friend class boost::serialization::access;
135
136 template<class Archive>
137 void serialize(Archive& ar, unsigned int version)
138 {
139 ar& BOOST_SERIALIZATION_NVP(iD);
140 ar& BOOST_SERIALIZATION_NVP(iN);
141 ar& BOOST_SERIALIZATION_NVP(lType);
142 ar& BOOST_SERIALIZATION_NVP(m_dType);
143
144 /*layertype_serializer a1(lType);
145 ar & boost::serialization::make_nvp("LayerType", a1);*/
146 }
147 };
148
149 }
150}
Abstract class for different kind of layers.
Definition: FgILayer.h:38
virtual ~ILayer()=default
Destructor.
ILayer(LayerType type, int numPoints, int outputDim)
Constructor.
Definition: FgILayer.h:50
virtual void UpdateParameters()=0
Updates the parameters.
virtual int GetNumParameters()=0
Gets number of parameters to be optimized.
LayerType lType
liklihood or gp layer
Definition: FgILayer.h:129
virtual void SetDataSize(int length, int dimension)
Sets data size.
Definition: FgILayer.h:111
ILayer()
Default constructor.
Definition: FgILayer.h:124
af::dtype m_dType
floating point precision flag for af::array
Definition: FgILayer.h:131
LayerType GetType()
Gets the layer type.
Definition: FgILayer.h:67
virtual void SetParameters(const af::array &param)=0
Sets the parameters for each optimization iteration.
virtual af::array GetParameters()=0
Gets the parameters for each optimization iteration.