Joseph Redmon
2015-01-27 153705226d8ca746478b69eeac9bc854766daa11
src/convolutional_layer.h
@@ -1,45 +1,72 @@
#ifndef CONVOLUTIONAL_LAYER_H
#define CONVOLUTIONAL_LAYER_H
#include "cuda.h"
#include "image.h"
#include "activations.h"
typedef struct {
    float learning_rate;
    float momentum;
    float decay;
    int batch;
    int h,w,c;
    int out_h, out_w, out_c;
    int n;
    int size;
    int stride;
    double *filters;
    double *filter_updates;
    double *filter_momentum;
    int pad;
    float *filters;
    float *filter_updates;
    double *biases;
    double *bias_updates;
    double *bias_momentum;
    float *biases;
    float *bias_updates;
    double *col_image;
    double *delta;
    double *output;
    float *col_image;
    float *delta;
    float *output;
    #ifdef GPU
    float * filters_gpu;
    float * filter_updates_gpu;
    float * biases_gpu;
    float * bias_updates_gpu;
    float * col_image_gpu;
    float * delta_gpu;
    float * output_gpu;
    #endif
    ACTIVATION activation;
} convolutional_layer;
convolutional_layer *make_convolutional_layer(int h, int w, int c, int n, int size, int stride, ACTIVATION activation);
void forward_convolutional_layer(const convolutional_layer layer, double *in);
void learn_convolutional_layer(convolutional_layer layer);
void update_convolutional_layer(convolutional_layer layer, double step, double momentum, double decay);
void visualize_convolutional_layer(convolutional_layer layer, char *window);
#ifdef GPU
void forward_convolutional_layer_gpu(convolutional_layer layer, float * in);
void backward_convolutional_layer_gpu(convolutional_layer layer, float * in, float * delta_gpu);
void update_convolutional_layer_gpu(convolutional_layer layer);
void push_convolutional_layer(convolutional_layer layer);
void pull_convolutional_layer(convolutional_layer layer);
void learn_bias_convolutional_layer_ongpu(convolutional_layer layer);
void bias_output_gpu(const convolutional_layer layer);
#endif
//void backward_convolutional_layer(convolutional_layer layer, double *input, double *delta);
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);
void resize_convolutional_layer(convolutional_layer *layer, int h, int w, int c);
void forward_convolutional_layer(const convolutional_layer layer, float *in);
void update_convolutional_layer(convolutional_layer layer);
image *visualize_convolutional_layer(convolutional_layer layer, char *window, image *prev_filters);
//void backpropagate_convolutional_layer_convolve(image input, convolutional_layer layer);
//void visualize_convolutional_filters(convolutional_layer layer, char *window);
//void visualize_convolutional_layer(convolutional_layer layer);
void backward_convolutional_layer(convolutional_layer layer, float *in, float *delta);
void bias_output(const convolutional_layer layer);
image get_convolutional_image(convolutional_layer layer);
image get_convolutional_delta(convolutional_layer layer);
image get_convolutional_filter(convolutional_layer layer, int i);
int convolutional_out_height(convolutional_layer layer);
int convolutional_out_width(convolutional_layer layer);
void learn_bias_convolutional_layer(convolutional_layer layer);
#endif