-
Notifications
You must be signed in to change notification settings - Fork 4
/
mlpLayer.h
114 lines (88 loc) · 3.98 KB
/
mlpLayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef AIFI__MLP_LAYER
#define AIFI__MLP_LAYER
// <INCLUDE> //
#include "popc.h"
#include "cell.h"
#include "layer.h"
#include "mlp.h"
#include "activation.h"
#include "loss.h"
#include "optimization.h"
// </INCLUDE> //
// <DELEGATION> //
// pending/
//delegation bool (fnPtr onMlpLayerPropagateForwardBeginDelegate) (mlp ptr nw, double ptr1d inputTable1d, int inputRowMax, int inputColumnMax, double ptr1d targetTable1d, int targetRowMax, int targetColumnMax, int epochCurrent);
//delegation bool (fnPtr onMlpLayerPropagateForwardEndDelegate) (mlp ptr nw, double ptr1d inputTable1d, int inputRowMax, int inputColumnMax, double ptr1d targetTable1d, int targetRowMax, int targetColumnMax, int epochCurrent);
//delegation bool (fnPtr onMlpLayerPropagateBackwardCalculationBeginDelegate) (mlp ptr nw, double ptr inputTuple1d, int inputColumnMax, double ptr targetTuple1d, int targetColumnMax);
//delegation bool (fnPtr onMlpLayerPropagateBackwardCalculationEndDelegate) (mlp ptr nw, double ptr inputTuple1d, int inputColumnMax, double ptr targetTuple1d, int targetColumnMax);
//delegation bool (fnPtr onMlpLayerPropagateBackwardLearningBeginDelegate) (mlp ptr nw, double ptr inputTuple1d, int inputColumnMax, double ptr targetTuple1d, int targetColumnMax);
//delegation bool (fnPtr onMlpLayerPropagateBackwardLearningEndDelegate) (mlp ptr nw, double ptr inputTuple1d, int inputColumnMax, double ptr targetTuple1d, int targetColumnMax);
// </DELEGATION> //
/* <FORWARD DECLARATION> *************/
subject mlp mlp; //FD!
/* </FORWARD DECLARATION> ************/
// <DEFINE> //
//#define REQUIRED STUFFS HERE
// </DEFINE> //
// -- V2 -- //
// <SUBJECT> //
subject mlpLayer {
// header
layerIndex index;
layerCellCount cellCount;
layerType lt;
cellType ct;
layerError error;
layerDeltaError deltaErrorGradient;
activationFunctionType aft;
lossFunctionType lft;
optimizationFunctionType oft;
double learningRate;
double learningMomentumRate;
// /header
// cell vector
cellConnectionCount ptr connectionCount1d;
cellInput ptr2d input2d;
cellWeight ptr2d weight2d;
cellOutput ptr output1d;
cellTarget ptr target1d;
cellError ptr outputError1d;
cellDeltaError ptr outputDeltaErrorGradient1d;
cellDeltaError ptr previousOutputDeltaErrorGradient1d;
cellBias ptr bias1d;
cellDeltaBias ptr biasDeltaGradient1d;
cellDeltaBias ptr previousBiasDeltaGradient1d;
activation ptr2d actFn2d;
loss ptr2d lossFn2d;
optimization ptr2d optFn2d;
// /cell vector
} mlpLayer;
// </SUBJECT> //
// <PROTOTYPE> //
pattern mlpLayerSingleton {
mlpLayer ptr (fnPtr mlpLayerAppend) (mlp ptr nw, int cellCount, layerType lt, cellType ct, activationFunctionType aft, lossFunctionType lft, optimizationFunctionType oft);
void (fnPtr mlpLayerDel) (mlpLayer ptr l);
void (fnPtr propagateForward) (mlpLayer ptr previousLayer, mlpLayer ptr currentLayer);
void (fnPtr propagateBackward) (mlpLayer ptr previousLayer, mlpLayer ptr currentLayer, mlpLayer ptr nextLayer, double learningRate, double learningMomentumRate);
void (fnPtr setInput) (mlpLayer ptr l, double ptr2d input2d);
//PENDING void (fnPtr setError) (mlpLayer ptr l, double ptr target);
} mlpLayerSingleton;
// </PROTOTYPE> //
#ifdef Cplusplus
extern "C" {
#endif
//
mlpLayerSingleton ptr mlpLayerSingletonNew ();
// /
//
mlpLayer ptr mlpLayerAppend (mlp ptr nw, int cellCount, layerType lt, cellType ct, activationFunctionType aft, lossFunctionType lft, optimizationFunctionType oft);
void mlpLayerDel (mlpLayer ptr l);
void mlpLayerPropagateForward (mlpLayer ptr previousLayer, mlpLayer ptr currentLayer);
void mlpLayerPropagateBackward (mlpLayer ptr previousLayer, mlpLayer ptr currentLayer, mlpLayer ptr nextLayer, double learningRate, double learningMomentumRate);
void mlpLayerSetInput (mlpLayer ptr l, double ptr2d input2d);
//PENDING void mlpLayerSetError (mlpLayer ptr l, double ptr target);
// /
#ifdef Cplusplus
}
#endif
#endif