From 0045074f56af003b0cb023fb1c50e41618b85390 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 07 May 2018 20:33:10 +0000
Subject: [PATCH] Get pre-trained weights for Yolo v3 tiny
---
src/deconvolutional_layer.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/deconvolutional_layer.c b/src/deconvolutional_layer.c
index d476957..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);
@@ -137,7 +141,7 @@
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;
@@ -167,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);
@@ -178,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;
@@ -193,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