Joseph Redmon
2016-09-08 336a19f14550ab1adbb0d9599284ac525fb6a5e0
src/maxpool_layer.c
@@ -18,7 +18,7 @@
    return float_to_image(w,h,c,l.delta);
}
maxpool_layer make_maxpool_layer(int batch, int h, int w, int c, int size, int stride)
maxpool_layer make_maxpool_layer(int batch, int h, int w, int c, int size, int stride, int padding)
{
    fprintf(stderr, "Maxpool Layer: %d x %d x %d image, %d size, %d stride\n", h,w,c,size,stride);
    maxpool_layer l = {0};
@@ -27,8 +27,9 @@
    l.h = h;
    l.w = w;
    l.c = c;
    l.out_w = (w-1)/stride + 1;
    l.out_h = (h-1)/stride + 1;
    l.pad = padding;
    l.out_w = (w + 2*padding - size + 1)/stride + 1;
    l.out_h = (h + 2*padding - size + 1)/stride + 1;
    l.out_c = c;
    l.outputs = l.out_h * l.out_w * l.out_c;
    l.inputs = h*w*c;
@@ -48,12 +49,12 @@
void resize_maxpool_layer(maxpool_layer *l, int w, int h)
{
    int stride = l->stride;
    l->h = h;
    l->w = w;
    l->inputs = h*w*l->c;
    l->out_w = (w-1)/stride + 1;
    l->out_h = (h-1)/stride + 1;
    l->out_w = (w + 2*l->pad - l->size + 1)/l->stride + 1;
    l->out_h = (h + 2*l->pad - l->size + 1)/l->stride + 1;
    l->outputs = l->out_w * l->out_h * l->c;
    int output_size = l->outputs * l->batch;
@@ -74,11 +75,11 @@
void forward_maxpool_layer(const maxpool_layer l, network_state state)
{
    int b,i,j,k,m,n;
    int w_offset = (-l.size-1)/2 + 1;
    int h_offset = (-l.size-1)/2 + 1;
    int w_offset = -l.pad;
    int h_offset = -l.pad;
    int h = (l.h-1)/l.stride + 1;
    int w = (l.w-1)/l.stride + 1;
    int h = l.out_h;
    int w = l.out_w;
    int c = l.c;
    for(b = 0; b < l.batch; ++b){
@@ -111,8 +112,8 @@
void backward_maxpool_layer(const maxpool_layer l, network_state state)
{
    int i;
    int h = (l.h-1)/l.stride + 1;
    int w = (l.w-1)/l.stride + 1;
    int h = l.out_h;
    int w = l.out_w;
    int c = l.c;
    for(i = 0; i < h*w*c*l.batch; ++i){
        int index = l.indexes[i];