From c6afc7ff1499fbbe64069e1843d7929bd7ae2eaa Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 17 Nov 2016 20:18:24 +0000
Subject: [PATCH] :fire: :fire: yolo v2 :fire: :fire:
---
src/reorg_layer.c | 44 +++++++++-----------------------------------
1 files changed, 9 insertions(+), 35 deletions(-)
diff --git a/src/reorg_layer.c b/src/reorg_layer.c
index d93dd97..9b68f03 100644
--- a/src/reorg_layer.c
+++ b/src/reorg_layer.c
@@ -23,7 +23,7 @@
l.out_c = c*(stride*stride);
}
l.reverse = reverse;
- fprintf(stderr, "Reorg Layer: %d x %d x %d image -> %d x %d x %d image, \n", w,h,c,l.out_w, l.out_h, l.out_c);
+ fprintf(stderr, "reorg /%2d %4d x%4d x%4d -> %4d x%4d x%4d\n", stride, w, h, c, l.out_w, l.out_h, l.out_c);
l.outputs = l.out_h * l.out_w * l.out_c;
l.inputs = h*w*c;
int output_size = l.out_h * l.out_w * l.out_c * batch;
@@ -77,45 +77,19 @@
void forward_reorg_layer(const layer l, network_state state)
{
- int b,i,j,k;
-
- for(b = 0; b < l.batch; ++b){
- for(k = 0; k < l.c; ++k){
- for(j = 0; j < l.h; ++j){
- for(i = 0; i < l.w; ++i){
- int in_index = i + l.w*(j + l.h*(k + l.c*b));
-
- int c2 = k % l.out_c;
- int offset = k / l.out_c;
- int w2 = i*l.stride + offset % l.stride;
- int h2 = j*l.stride + offset / l.stride;
- int out_index = w2 + l.out_w*(h2 + l.out_h*(c2 + l.out_c*b));
- l.output[out_index] = state.input[in_index];
- }
- }
- }
+ if(l.reverse){
+ reorg_cpu(state.input, l.w, l.h, l.c, l.batch, l.stride, 1, l.output);
+ }else {
+ reorg_cpu(state.input, l.w, l.h, l.c, l.batch, l.stride, 0, l.output);
}
}
void backward_reorg_layer(const layer l, network_state state)
{
- int b,i,j,k;
-
- for(b = 0; b < l.batch; ++b){
- for(k = 0; k < l.c; ++k){
- for(j = 0; j < l.h; ++j){
- for(i = 0; i < l.w; ++i){
- int in_index = i + l.w*(j + l.h*(k + l.c*b));
-
- int c2 = k % l.out_c;
- int offset = k / l.out_c;
- int w2 = i*l.stride + offset % l.stride;
- int h2 = j*l.stride + offset / l.stride;
- int out_index = w2 + l.out_w*(h2 + l.out_h*(c2 + l.out_c*b));
- state.delta[in_index] = l.delta[out_index];
- }
- }
- }
+ if(l.reverse){
+ reorg_cpu(l.delta, l.w, l.h, l.c, l.batch, l.stride, 0, state.delta);
+ }else{
+ reorg_cpu(l.delta, l.w, l.h, l.c, l.batch, l.stride, 1, state.delta);
}
}
--
Gitblit v1.10.0