2013-11-04 23:11:01 +04:00
|
|
|
#ifndef CONVOLUTIONAL_LAYER_H
|
|
|
|
#define CONVOLUTIONAL_LAYER_H
|
|
|
|
|
|
|
|
#include "image.h"
|
2013-11-13 22:50:38 +04:00
|
|
|
#include "activations.h"
|
2013-11-04 23:11:01 +04:00
|
|
|
|
|
|
|
typedef struct {
|
2013-11-13 22:50:38 +04:00
|
|
|
int h,w,c;
|
2013-11-04 23:11:01 +04:00
|
|
|
int n;
|
|
|
|
int stride;
|
|
|
|
image *kernels;
|
|
|
|
image *kernel_updates;
|
2013-11-13 22:50:38 +04:00
|
|
|
double *biases;
|
|
|
|
double *bias_updates;
|
2013-11-04 23:11:01 +04:00
|
|
|
image upsampled;
|
2013-11-13 22:50:38 +04:00
|
|
|
double *delta;
|
|
|
|
double *output;
|
|
|
|
|
|
|
|
double (* activation)();
|
|
|
|
double (* gradient)();
|
2013-11-04 23:11:01 +04:00
|
|
|
} convolutional_layer;
|
|
|
|
|
2013-11-13 22:50:38 +04:00
|
|
|
convolutional_layer *make_convolutional_layer(int h, int w, int c, int n, int size, int stride, ACTIVATION activator);
|
|
|
|
void forward_convolutional_layer(const convolutional_layer layer, double *in);
|
|
|
|
void backward_convolutional_layer(convolutional_layer layer, double *input, double *delta);
|
|
|
|
void learn_convolutional_layer(convolutional_layer layer, double *input);
|
|
|
|
|
2013-11-07 04:09:41 +04:00
|
|
|
void update_convolutional_layer(convolutional_layer layer, double step);
|
2013-11-13 22:50:38 +04:00
|
|
|
|
2013-11-07 04:09:41 +04:00
|
|
|
void backpropagate_convolutional_layer_convolve(image input, convolutional_layer layer);
|
2013-11-13 22:50:38 +04:00
|
|
|
void visualize_convolutional_layer(convolutional_layer layer);
|
|
|
|
|
|
|
|
image get_convolutional_image(convolutional_layer layer);
|
|
|
|
image get_convolutional_delta(convolutional_layer layer);
|
2013-11-04 23:11:01 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|