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
20 namespace 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}
NeuralEngine::MachineLearning::CommonUtil
Definition: CommonUtil.h:37
NeuralEngine::MachineLearning::ILayer
Abstract class for different kind of layers.
Definition: FgILayer.h:38
NeuralEngine::MachineLearning::ILayer::~ILayer
virtual ~ILayer()=default
Destructor.
NeuralEngine::MachineLearning::ILayer::ILayer
ILayer(LayerType type, int numPoints, int outputDim)
Constructor.
Definition: FgILayer.h:50
NeuralEngine::MachineLearning::ILayer::UpdateParameters
virtual void UpdateParameters()=0
Updates the parameters.
NeuralEngine::MachineLearning::ILayer::GetNumParameters
virtual int GetNumParameters()=0
Gets number of parameters to be optimized.
NeuralEngine::MachineLearning::ILayer::lType
LayerType lType
liklihood or gp layer
Definition: FgILayer.h:129
NeuralEngine::MachineLearning::ILayer::SetDataSize
virtual void SetDataSize(int length, int dimension)
Sets data size.
Definition: FgILayer.h:111
NeuralEngine::MachineLearning::ILayer::ILayer
ILayer()
Default constructor.
Definition: FgILayer.h:124
NeuralEngine::MachineLearning::ILayer::m_dType
af::dtype m_dType
floating point precision flag for af::array
Definition: FgILayer.h:131
NeuralEngine::MachineLearning::ILayer::GetType
LayerType GetType()
Gets the layer type.
Definition: FgILayer.h:67
NeuralEngine::MachineLearning::ILayer::iD
int iD
data dimension
Definition: FgILayer.h:126
NeuralEngine::MachineLearning::ILayer::SetParameters
virtual void SetParameters(const af::array &param)=0
Sets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::ILayer::GetParameters
virtual af::array GetParameters()=0
Gets the parameters for each optimization iteration.
NeuralEngine::MachineLearning::ILayer::iN
int iN
data size
Definition: FgILayer.h:127
Scalar
NeuralEngine
Definition: NeArray2.h:18