From a9c0a8b2b516ca20abc1fbe7158b97a34f92b23f Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 02 Jan 2017 12:24:11 +0000
Subject: [PATCH] Minor fix for pragma-lib
---
src/deconvolutional_layer.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/deconvolutional_layer.c b/src/deconvolutional_layer.c
index 0f4e1e8..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);
}
@@ -166,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);
@@ -177,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;
@@ -192,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