2013-11-04 23:11:01 +04:00
|
|
|
// Oh boy, why am I about to do this....
|
|
|
|
#ifndef NETWORK_H
|
|
|
|
#define NETWORK_H
|
|
|
|
|
2014-05-10 02:14:52 +04:00
|
|
|
#include "opencl.h"
|
2013-11-04 23:11:01 +04:00
|
|
|
#include "image.h"
|
2013-11-13 22:50:38 +04:00
|
|
|
#include "data.h"
|
2013-11-04 23:11:01 +04:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CONVOLUTIONAL,
|
|
|
|
CONNECTED,
|
2013-12-03 04:41:40 +04:00
|
|
|
MAXPOOL,
|
2014-04-17 04:05:29 +04:00
|
|
|
SOFTMAX,
|
2014-08-08 23:04:15 +04:00
|
|
|
NORMALIZATION,
|
2014-08-11 23:52:07 +04:00
|
|
|
DROPOUT,
|
2014-10-13 11:29:01 +04:00
|
|
|
FREEWEIGHT,
|
|
|
|
CROP,
|
|
|
|
COST
|
2013-11-04 23:11:01 +04:00
|
|
|
} LAYER_TYPE;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int n;
|
2014-03-13 08:57:34 +04:00
|
|
|
int batch;
|
2014-08-08 23:04:15 +04:00
|
|
|
float learning_rate;
|
|
|
|
float momentum;
|
|
|
|
float decay;
|
2013-11-04 23:11:01 +04:00
|
|
|
void **layers;
|
|
|
|
LAYER_TYPE *types;
|
2013-12-07 01:26:09 +04:00
|
|
|
int outputs;
|
2014-01-29 04:28:42 +04:00
|
|
|
float *output;
|
2014-05-10 02:14:52 +04:00
|
|
|
|
|
|
|
#ifdef GPU
|
2014-10-17 02:17:23 +04:00
|
|
|
cl_mem *input_cl;
|
|
|
|
cl_mem *truth_cl;
|
2014-05-10 02:14:52 +04:00
|
|
|
#endif
|
2013-11-04 23:11:01 +04:00
|
|
|
} network;
|
|
|
|
|
2014-12-17 02:34:10 +03:00
|
|
|
#ifdef GPU
|
|
|
|
float train_network_datum_gpu(network net, float *x, float *y);
|
2014-11-06 01:49:58 +03:00
|
|
|
float *network_predict_gpu(network net, float *input);
|
2014-12-17 02:34:10 +03:00
|
|
|
#endif
|
2014-08-28 06:11:46 +04:00
|
|
|
|
2014-03-13 08:57:34 +04:00
|
|
|
network make_network(int n, int batch);
|
2014-10-13 11:29:01 +04:00
|
|
|
void forward_network(network net, float *input, float *truth, int train);
|
|
|
|
void backward_network(network net, float *input);
|
2014-08-08 23:04:15 +04:00
|
|
|
void update_network(network net);
|
2014-12-17 02:34:10 +03:00
|
|
|
|
|
|
|
float train_network(network net, data d);
|
2014-08-08 23:04:15 +04:00
|
|
|
float train_network_batch(network net, data d, int n);
|
2014-12-17 02:34:10 +03:00
|
|
|
float train_network_sgd(network net, data d, int n);
|
|
|
|
|
2013-12-07 21:38:50 +04:00
|
|
|
matrix network_predict_data(network net, data test);
|
2014-10-25 22:57:26 +04:00
|
|
|
float *network_predict(network net, float *input);
|
2014-01-29 04:28:42 +04:00
|
|
|
float network_accuracy(network net, data d);
|
2014-12-17 02:34:10 +03:00
|
|
|
float *network_accuracies(network net, data d);
|
2014-08-11 23:52:07 +04:00
|
|
|
float network_accuracy_multi(network net, data d, int n);
|
2014-10-25 22:57:26 +04:00
|
|
|
void top_predictions(network net, int n, int *index);
|
2014-01-29 04:28:42 +04:00
|
|
|
float *get_network_output(network net);
|
|
|
|
float *get_network_output_layer(network net, int i);
|
|
|
|
float *get_network_delta_layer(network net, int i);
|
|
|
|
float *get_network_delta(network net);
|
2013-11-07 04:09:41 +04:00
|
|
|
int get_network_output_size_layer(network net, int i);
|
2013-11-13 22:50:38 +04:00
|
|
|
int get_network_output_size(network net);
|
2013-11-04 23:11:01 +04:00
|
|
|
image get_network_image(network net);
|
2013-11-07 04:09:41 +04:00
|
|
|
image get_network_image_layer(network net, int i);
|
2013-12-07 01:26:09 +04:00
|
|
|
int get_predicted_class_network(network net);
|
2013-12-03 04:41:40 +04:00
|
|
|
void print_network(network net);
|
|
|
|
void visualize_network(network net);
|
2014-03-13 08:57:34 +04:00
|
|
|
int resize_network(network net, int h, int w, int c);
|
2014-12-12 00:15:26 +03:00
|
|
|
void set_batch_network(network *net, int b);
|
|
|
|
void set_learning_network(network *net, float rate, float momentum, float decay);
|
2014-05-10 02:14:52 +04:00
|
|
|
int get_network_input_size(network net);
|
2014-10-13 11:29:01 +04:00
|
|
|
float get_network_cost(network net);
|
2013-11-04 23:11:01 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|