-
Notifications
You must be signed in to change notification settings - Fork 1
/
cnn_in_one_page.h
161 lines (138 loc) · 2.38 KB
/
cnn_in_one_page.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/timeb.h>
#include <pthread.h>
typedef enum {
NET,
CONVOLUTIONAL,
CONNECTED,
MAXPOOL,
SOFTMAX
}LAYER_TYPE;
typedef enum {
RELU,
ELU,
MAXOUT
}ACT_TYPE;
typedef struct matrix_ {
int nrows;
int ncols;
int nchannels;
float *vals;
}MATRIX;
typedef struct data_{
int h;
int w;
MATRIX *X;
MATRIX *y; // labels, one-hot encoded
}DATA;
typedef struct update_args_ { // update parameters
int batch;
float learning_rate;
float momentum;
float decay;
int adam;
float B1;
float B2;
float eps;
int t;
}UPDATE_ARGS;
typedef struct load_args_{ // load parameters
char **paths;
char *path;
int n;
int m;
const char **labels;
int h;
int w;
int out_w;
int out_h;
int nh;
int nw;
int min;
int max;
int size;
float aspect;
int classes;
DATA *data;
}LOAD_ARGS;
struct network_;
typedef struct network_ NETWORK;
struct layer_;
typedef struct layer_ LAYER;
struct layer_ {
int layer_type;
int activation;
int batch;
int inputs;
int outputs;
int groups;
int nweights;
int nbiases;
int h;
int w;
int c;
int out_h;
int out_w;
int out_c;
int n;
int size;
int stride;
int padding;
int truths;
int softmax;
float temperature;
float cost;
int *indexes;
float *biases;
float *bias_updates;
float *scales;
float *scale_updates;
float *weights;
float *weight_updates;
float *delta;
float *output;
float *loss;
float truth;
float *x;
float *x_norm;
float *workspace;
int workspace_size;
};
struct network_ {
int n;
int batch;
float epoch;
LAYER **layers; // all layers
LAYER *layers0; // copy of layer0
float *output;
float learning_rate;
float momentum;
float decay;
int adam;
float B1;
float B2;
float eps;
int inputs;
int outputs;
int h;
int w;
int c;
float aspect;
float *input;
float *truth;
float *delta;
float *workspace;
int workspace_size;
int seen;
int t;
int time_steps;
int subdivisions;
int max_batches;
int truths;
int train;
int index;
float cost;
};