From c9b8bdee1886df5f83973d91c3597c28f99a9e0c Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Sun, 06 May 2018 18:51:31 +0000
Subject: [PATCH] Minor fix - what pip-packages are required for Python scripts

---
 src/deconvolutional_layer.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/deconvolutional_layer.c b/src/deconvolutional_layer.c
index 524fc95..fbef9d5 100644
--- a/src/deconvolutional_layer.c
+++ b/src/deconvolutional_layer.c
@@ -57,13 +57,13 @@
     l.stride = stride;
     l.size = size;
 
-    l.filters = calloc(c*n*size*size, sizeof(float));
-    l.filter_updates = calloc(c*n*size*size, sizeof(float));
+    l.weights = calloc(c*n*size*size, sizeof(float));
+    l.weight_updates = calloc(c*n*size*size, sizeof(float));
 
     l.biases = calloc(n, sizeof(float));
     l.bias_updates = calloc(n, sizeof(float));
     float scale = 1./sqrt(size*size*c);
-    for(i = 0; i < c*n*size*size; ++i) l.filters[i] = scale*rand_normal();
+    for(i = 0; i < c*n*size*size; ++i) l.weights[i] = scale*rand_normal();
     for(i = 0; i < n; ++i){
         l.biases[i] = scale;
     }
@@ -80,9 +80,13 @@
     l.output = calloc(l.batch*out_h * out_w * n, sizeof(float));
     l.delta  = calloc(l.batch*out_h * out_w * n, sizeof(float));
 
+    l.forward = forward_deconvolutional_layer;
+    l.backward = backward_deconvolutional_layer;
+    l.update = update_deconvolutional_layer;
+
     #ifdef GPU
-    l.filters_gpu = cuda_make_array(l.filters, c*n*size*size);
-    l.filter_updates_gpu = cuda_make_array(l.filter_updates, c*n*size*size);
+    l.weights_gpu = cuda_make_array(l.weights, c*n*size*size);
+    l.weight_updates_gpu = cuda_make_array(l.weight_updates, c*n*size*size);
 
     l.biases_gpu = cuda_make_array(l.biases, n);
     l.bias_updates_gpu = cuda_make_array(l.bias_updates, n);
@@ -134,10 +138,10 @@
     int n = l.h*l.w;
     int k = l.c;
 
-    bias_output(l.output, l.biases, l.batch, l.n, size);
+    fill_cpu(l.outputs*l.batch, 0, l.output, 1);
 
     for(i = 0; i < l.batch; ++i){
-        float *a = l.filters;
+        float *a = l.weights;
         float *b = state.input + i*l.c*l.h*l.w;
         float *c = l.col_image;
 
@@ -145,6 +149,7 @@
 
         col2im_cpu(c, l.n, out_h, out_w, l.size, l.stride, 0, l.output+i*l.n*size);
     }
+    add_bias(l.output, l.biases, l.batch, l.n, size);
     activate_array(l.output, l.batch*l.n*size, l.activation);
 }
 
@@ -159,8 +164,6 @@
     gradient_array(l.output, size*l.n*l.batch, l.activation, l.delta);
     backward_bias(l.bias_updates, l.delta, l.batch, l.n, size);
 
-    if(state.delta) memset(state.delta, 0, l.batch*l.h*l.w*l.c*sizeof(float));
-
     for(i = 0; i < l.batch; ++i){
         int m = l.c;
         int n = l.size*l.size*l.n;
@@ -168,7 +171,7 @@
 
         float *a = state.input + i*m*n;
         float *b = l.col_image;
-        float *c = l.filter_updates;
+        float *c = l.weight_updates;
 
         im2col_cpu(l.delta + i*l.n*size, l.n, out_h, out_w, 
                 l.size, l.stride, 0, b);
@@ -179,7 +182,7 @@
             int n = l.h*l.w;
             int k = l.size*l.size*l.n;
 
-            float *a = l.filters;
+            float *a = l.weights;
             float *b = l.col_image;
             float *c = state.delta + i*n*m;
 
@@ -194,9 +197,9 @@
     axpy_cpu(l.n, learning_rate, l.bias_updates, 1, l.biases, 1);
     scal_cpu(l.n, momentum, l.bias_updates, 1);
 
-    axpy_cpu(size, -decay, l.filters, 1, l.filter_updates, 1);
-    axpy_cpu(size, learning_rate, l.filter_updates, 1, l.filters, 1);
-    scal_cpu(size, momentum, l.filter_updates, 1);
+    axpy_cpu(size, -decay, l.weights, 1, l.weight_updates, 1);
+    axpy_cpu(size, learning_rate, l.weight_updates, 1, l.weights, 1);
+    scal_cpu(size, momentum, l.weight_updates, 1);
 }
 
 

--
Gitblit v1.10.0