darknet/src/convolutional_layer.h

73 lines
2.2 KiB
C
Raw Normal View History

2013-11-04 23:11:01 +04:00
#ifndef CONVOLUTIONAL_LAYER_H
#define CONVOLUTIONAL_LAYER_H
2015-01-23 03:38:24 +03:00
#include "cuda.h"
2013-11-04 23:11:01 +04:00
#include "image.h"
2013-11-13 22:50:38 +04:00
#include "activations.h"
2013-11-04 23:11:01 +04:00
typedef struct {
2014-08-08 23:04:15 +04:00
float learning_rate;
float momentum;
float decay;
2014-03-13 08:57:34 +04:00
int batch;
2013-11-13 22:50:38 +04:00
int h,w,c;
2013-11-04 23:11:01 +04:00
int n;
2013-12-03 04:41:40 +04:00
int size;
2013-11-04 23:11:01 +04:00
int stride;
2014-07-14 09:07:51 +04:00
int pad;
float *filters;
float *filter_updates;
2014-01-28 11:16:56 +04:00
float *biases;
float *bias_updates;
2014-01-28 11:16:56 +04:00
float *col_image;
float *delta;
float *output;
2013-11-13 22:50:38 +04:00
2014-05-10 02:14:52 +04:00
#ifdef GPU
2015-01-23 03:38:24 +03:00
float * filters_gpu;
float * filter_updates_gpu;
2014-05-10 02:14:52 +04:00
2015-01-23 03:38:24 +03:00
float * biases_gpu;
float * bias_updates_gpu;
2014-05-10 02:14:52 +04:00
2015-01-23 03:38:24 +03:00
float * col_image_gpu;
float * delta_gpu;
float * output_gpu;
2014-05-10 02:14:52 +04:00
#endif
2013-12-03 04:41:40 +04:00
ACTIVATION activation;
2013-11-04 23:11:01 +04:00
} convolutional_layer;
2014-05-10 02:14:52 +04:00
#ifdef GPU
2015-01-23 03:38:24 +03:00
void forward_convolutional_layer_gpu(convolutional_layer layer, float * in);
void backward_convolutional_layer_gpu(convolutional_layer layer, float * in, float * delta_gpu);
2014-10-13 11:29:01 +04:00
void update_convolutional_layer_gpu(convolutional_layer layer);
2014-10-25 22:57:26 +04:00
void push_convolutional_layer(convolutional_layer layer);
2015-01-13 04:27:08 +03:00
void pull_convolutional_layer(convolutional_layer layer);
2015-01-23 03:38:24 +03:00
void learn_bias_convolutional_layer_ongpu(convolutional_layer layer);
void bias_output_gpu(const convolutional_layer layer);
2014-05-10 02:14:52 +04:00
#endif
2014-08-08 23:04:15 +04:00
convolutional_layer *make_convolutional_layer(int batch, int h, int w, int c, int n, int size, int stride, int pad, ACTIVATION activation, float learning_rate, float momentum, float decay);
2014-03-13 08:57:34 +04:00
void resize_convolutional_layer(convolutional_layer *layer, int h, int w, int c);
void forward_convolutional_layer(const convolutional_layer layer, float *in);
2014-08-08 23:04:15 +04:00
void update_convolutional_layer(convolutional_layer layer);
image *visualize_convolutional_layer(convolutional_layer layer, char *window, image *prev_filters);
2014-01-28 11:16:56 +04:00
2014-12-04 10:20:29 +03:00
void backward_convolutional_layer(convolutional_layer layer, float *in, float *delta);
2013-11-13 22:50:38 +04:00
2015-01-23 03:38:24 +03:00
void bias_output(const convolutional_layer layer);
2013-11-13 22:50:38 +04:00
image get_convolutional_image(convolutional_layer layer);
image get_convolutional_delta(convolutional_layer layer);
2014-01-28 11:16:56 +04:00
image get_convolutional_filter(convolutional_layer layer, int i);
2013-11-04 23:11:01 +04:00
2015-01-23 03:38:24 +03:00
int convolutional_out_height(convolutional_layer layer);
int convolutional_out_width(convolutional_layer layer);
void learn_bias_convolutional_layer(convolutional_layer layer);
2013-11-04 23:11:01 +04:00
#endif