-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnet.h
39 lines (34 loc) · 1.66 KB
/
net.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
/********************************************************************************
* *
* net.h *
* *
* A MultiLayer Deep Neural Network Backpropagation implementation *
* *
* srand(time(NULL)); should be used before net_init() to randomize weights *
* *
********************************************************************************/
#ifndef NET_H
#define NET_H
typedef struct {
double** neuron;
double*** weight; /* weights go backwards */
int* npl; /* neuron per layer */
int num_layers; /* io included */
double* d_out; /* delta of output layer */
double** d_hid; /* delta of hidden layer */
char activation[10]; /* activation for every layer but input */
} network;
double random_weight();
network* net_init(int num_layers, int* nrns_per_layer, char* activation);
float sigmoid(float a);
float sig_der(float a);
void forward(network* net, double input[]);
void net_print(network* net);
double out_err(network* net, double output[]);
void delta_out(network* net, double output[]);
int max_tbl(int tbl[], int len);
void delta_hid(network* net);
int adjust_weights(network* net, double lr);
int train(network* net, double* input, double* output, int length, double lr,
double err_tgt);
#endif /* NET_H */