From 2b4e07f13e94a5fe36dcdb28156c70540eaadcb6 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 10 Jul 2015 23:38:39 +0000
Subject: [PATCH] small parser change

---
 src/convolutional_layer.c |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/convolutional_layer.c b/src/convolutional_layer.c
index b6437d4..c266934 100644
--- a/src/convolutional_layer.c
+++ b/src/convolutional_layer.c
@@ -61,7 +61,8 @@
 
     l.biases = calloc(n, sizeof(float));
     l.bias_updates = calloc(n, sizeof(float));
-    float scale = 1./sqrt(size*size*c);
+    //float scale = 1./sqrt(size*size*c);
+    float scale = sqrt(2./(size*size*c));
     for(i = 0; i < c*n*size*size; ++i) l.filters[i] = 2*scale*rand_uniform() - scale;
     for(i = 0; i < n; ++i){
         l.biases[i] = scale;
@@ -96,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));
@@ -115,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
 }
 
@@ -226,6 +233,17 @@
     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);
+        }
+    }
+}
+
 image *get_filters(convolutional_layer l)
 {
     image *filters = calloc(l.n, sizeof(image));

--
Gitblit v1.10.0