From 0b4c38f631db13e2db18423e9a12ec4885f03b8b Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 31 Jul 2015 05:12:29 +0000
Subject: [PATCH] Set default subdivisions to be larger
---
src/convolutional_layer.c | 45 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/src/convolutional_layer.c b/src/convolutional_layer.c
index 67c36c3..7dcf5a4 100644
--- a/src/convolutional_layer.c
+++ b/src/convolutional_layer.c
@@ -97,12 +97,18 @@
return l;
}
-void resize_convolutional_layer(convolutional_layer *l, int h, int w)
+void resize_convolutional_layer(convolutional_layer *l, int w, int h)
{
- l->h = h;
l->w = w;
- int out_h = convolutional_out_height(*l);
+ l->h = h;
int out_w = convolutional_out_width(*l);
+ int out_h = convolutional_out_height(*l);
+
+ l->out_w = out_w;
+ l->out_h = out_h;
+
+ l->outputs = l->out_h * l->out_w * l->out_c;
+ l->inputs = l->w * l->h * l->c;
l->col_image = realloc(l->col_image,
out_h*out_w*l->size*l->size*l->c*sizeof(float));
@@ -116,9 +122,9 @@
cuda_free(l->delta_gpu);
cuda_free(l->output_gpu);
- l->col_image_gpu = cuda_make_array(l->col_image, out_h*out_w*l->size*l->size*l->c);
- l->delta_gpu = cuda_make_array(l->delta, l->batch*out_h*out_w*l->n);
- l->output_gpu = cuda_make_array(l->output, l->batch*out_h*out_w*l->n);
+ l->col_image_gpu = cuda_make_array(0, out_h*out_w*l->size*l->size*l->c);
+ l->delta_gpu = cuda_make_array(0, l->batch*out_h*out_w*l->n);
+ l->output_gpu = cuda_make_array(0, l->batch*out_h*out_w*l->n);
#endif
}
@@ -182,8 +188,6 @@
gradient_array(l.output, m*k*l.batch, l.activation, l.delta);
backward_bias(l.bias_updates, l.delta, l.batch, l.n, k);
- if(state.delta) memset(state.delta, 0, l.batch*l.h*l.w*l.c*sizeof(float));
-
for(i = 0; i < l.batch; ++i){
float *a = l.delta + i*m*k;
float *b = l.col_image;
@@ -227,12 +231,37 @@
return float_to_image(w,h,c,l.filters+i*h*w*c);
}
+void rgbgr_filters(convolutional_layer l)
+{
+ int i;
+ for(i = 0; i < l.n; ++i){
+ image im = get_convolutional_filter(l, i);
+ if (im.c == 3) {
+ rgbgr_image(im);
+ }
+ }
+}
+
+void rescale_filters(convolutional_layer l, float scale, float trans)
+{
+ int i;
+ for(i = 0; i < l.n; ++i){
+ image im = get_convolutional_filter(l, i);
+ if (im.c == 3) {
+ scale_image(im, scale);
+ float sum = sum_array(im.data, im.w*im.h*im.c);
+ l.biases[i] += sum*trans;
+ }
+ }
+}
+
image *get_filters(convolutional_layer l)
{
image *filters = calloc(l.n, sizeof(image));
int i;
for(i = 0; i < l.n; ++i){
filters[i] = copy_image(get_convolutional_filter(l, i));
+ normalize_image(filters[i]);
}
return filters;
}
--
Gitblit v1.10.0