-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontpropagation.h
183 lines (166 loc) · 8.26 KB
/
frontpropagation.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* @Descripttion: all function about front propagation method
* @version: 2.0
* @Author: Quikziii
* @email: [email protected]
* @Date: 2023-01-26
* @LastEditors: Quikziii
* @LastEditTime: 2023-04-30
*/
#ifndef _FRONTPROPAGATION_H
#define _FRONTPROPAGATION_H
/**
* @name: Front_ReLU
* @msg: ReLu function if value below than 0 equal to 0
* @param {struct Matrix} *input - (input)the feature which need to process ReLU
* @param {struct Matrix} *output - (output)the feature after process ReLU
* @return {}
*/
void Front_ReLU (struct Matrix *input,struct Matrix *output);
/**
* @name: Front_ReLU
* @msg: ReLu function if value below than 0 equal to 0
* @param {struct Matrix} **input - (input)the feature batch which need to process ReLU
* @param {struct Matrix} **output - (output)the feature batch after process ReLU
* @return {}
*/
void FrontBatch_ReLU (struct Matrix **input,struct Matrix **output);
/**
* @name: Front_MaxPooLing
* @msg: apply maxPooling process to the feature
* @param {struct Matrix} *input - (input)the feature which need to process max pooling
* @param {struct Matrix} *output - (output)the feature which after max pooling
* @param {int} poolingSize - (input)the size of the poolng kernel
* @param {int} paddingAmt - (input)the size need to be padding
* @param {int} stride - (input)the stride(step) the kernel move per steps
* @return {}
*/
void Front_MaxPooLing(struct Matrix *input,struct Matrix *output,int poolingSize,int paddingAmt,int stride);
/**
* @name: FrontBatch_MaxPooLing
* @msg: apply maxPooling process to the Batch feature
* @param {struct Matrix} **input - (input)the Batch of feature which need to process max pooling
* @param {struct Matrix} **output - (output)the Batch of feature which after max pooling
* @param {int} poolingSize - (input)the size of the poolng kernel
* @param {int} paddingAmt - (input)the size need to be padding
* @param {int} stride - (input)the stride(step) the kernel move per steps
* @return {}
*/
void FrontBatch_MaxPooLing(struct Matrix **input,struct Matrix **output,int poolingSize,int paddingAmt,int stride);
/**
* @name: FrontBatch_Convolution
* @msg: Convolution the batch of feature with the kernel
* @param {struct Matrix} **input - (input)the image which need to process convolution
* @param {struct Matrix} **kernel - (input)the kernels which provided to convolution
* @param {struct Matrix} **output - (output)the Batch of struct which store the ans
* @param {int} padingAmt - (input)the size need to be padding
* @param {int} stride - (input)the stride(step) the kernel move per steps
* @return {}
*/
void FrontBatch_Convolution(struct Matrix **input,struct Matrix **kernel,struct Matrix **output ,int paddingAmt,int stride);
/**
* @name: Front_GlobalAverage
* @msg: apply global average pooling process to the feature(after become feature = chX1X1)
* @param {struct Matrix} *input - (input)the feature which need to process global average pooling
* @param {struct Matrix} *output - (output)the feature which after global average pooling
* @return {}
*/
void Front_GlobalAverage(struct Matrix *input,struct Matrix *output);
/**
* @name: Front_GlobalAverage
* @msg: apply global average pooling process to the batch of feature(after become feature = 1XchannelX1)
* @param {struct Matrix} **input - (input)the batch of feature which need to process global average pooling
* @param {struct Matrix} **output - (output)the batch of feature which after global average pooling
* @return {}
*/
void FrontBatch_GlobalAverage(struct Matrix **input,struct Matrix **output);
/**
* @name: Front_FullConnect
* @msg: apply full connect to the fecture (1XrowX1) with weight (1XpredictsizeXrow) and return (1XpredictsizeX1)
* @param {struct Matrix} **input - (input)the feature which need to fullconnect
* @param {struct Matrix} *weight - (input)the weight of the fc layer
* @param {struct Matrix} **output - (output)the feature after fullconncect
* @param {struct Matrix} *bias - (input)the bias of the fc layer
* @return {}
*/
void Front_FullConnect(struct Matrix *input,struct Matrix *weight,struct Matrix *output,struct Matrix *bias);
/**
* @name: FrontBatch_FullConnect
* @msg: apply full connect to the batch of fecture (1XrowX1) with weight (1XpredictsizeXrow) and return (1XpredictsizeX1)
* @param {struct Matrix} **input - (input)the batch of feature which need to fullconnect
* @param {struct Matrix} *weight - (input)the weight of the fc layer
* @param {struct Matrix} **output - (output)the batch of feature after fullconncect
* @param {struct Matrix} *bias - (input)the bias of the fc layer
* @return {}
*/
void FrontBatch_FUllConnct(struct Matrix **input,struct Matrix *weight,struct Matrix **output,struct Matrix *bias);
/**
* @name: Front_Softmax
* @msg: activation function
* @param {struct Matrix} *input - (input)the feature need to be activated
* @param {int} maximun - (input) index of the maximun term
* @param {struct Matrix} *output - (output)the feature after activated
* @return {}
*/
void Front_Softmax(struct Matrix *input,int maximun,struct Matrix *output);
/**
* @name: FrontBatch_Softmax
* @msg: activation function for batch
* @param {struct Matrix} **input - (input)the batch of feature need to be activated
* @param {int} *maximun - (input) the maximun of each logits
* @param {struct Matrix} **output - (output)the batch of feature after activated
* @return {}
*/
void FrontBatch_Softmax(struct Matrix **input,int *maximun,struct Matrix **output);
/**
* @name: Front_Predict
* @msg: return the prediction of the front propagation
* @param {struct Matrix} *input - (input)the values list after softmax
* @return {int} the index of the prediction
*/
int Front_Predict(struct Matrix *input);
/**
* @name: FrontBatch_Predict
* @msg: return the prediction lisy of the front propagation
* @param {struct Matrix} **input - (input)the values list after softmax
* @param {int} *output - (output)the predict ans list
* @return {}
*/
void FrontBatch_Predict(struct Matrix **input, int *output);
/**
* @name: Res_Sum
* @msg: residual block with Sum
* @param {struct Matrix} *input - (input)the term after bottleneck
* @param {struct Matrix} *lastInput - (input)the term before bottleneck
* @param {struct Matrix} *output - (output)the ans of residual
* @return {}
*/
void Res_Sum(struct Matrix *input , struct Matrix *lastInput, struct Matrix *output);
/**
* @name: Res_Sum
* @msg: residual block with Sum
* @param {struct Matrix} **input - (input)the batch of term after bottleneck
* @param {struct Matrix} **lastInput - (input)the batch of term before bottleneck
* @param {struct Matrix} **output - (output)the batch of ans of residual
* @return {}
*/
void ResBatch_Sum(struct Matrix **input , struct Matrix **lastInput, struct Matrix **output);
/**
* @name: Front_Accurancy
* @msg: calculate the error of the iterate
* @param {int} *input - (input)the list of each predict values
* @param {int} *testCaseLabel - (input)the list of ans of each picture
* @param {int} index - (input)the firstindex of the list
* @return {float} the value of the accurancy(error)
*/
float FrontBatch_Accurancy(int *input,int *testCaseLabel,int index);
/**
* @name: Front_LossFunction
* @msg: calculate the loss function of the iterate
* @param {struct Matrix} **input - (input)batch of the feature after softmax
* @param {int} *testCaseLabel - (input)the list of ans of each picture
* @param {int} index - (input)the firstindex of the list
* @return {float} the value of the costfunction(error)
*/
float FrontBatch_LossFunction(struct Matrix **input,int *testCaseLabel,int index);
#endif