From 47528e37cf29e0f9da6885213e5aee044bed84ef Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 15 Apr 2015 08:04:38 +0000
Subject: [PATCH] crop layer scaling and trans on cpu
---
src/crop_layer.c | 4 +++-
src/detection.c | 2 --
src/cost_layer.c | 19 ++++++++++---------
Makefile | 2 +-
src/activations.h | 3 ++-
5 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
index 63cb621..0e185f7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-GPU=1
+GPU=0
DEBUG=0
ARCH= -arch=sm_52
diff --git a/src/activations.h b/src/activations.h
index 07c5b5e..0aa61c2 100644
--- a/src/activations.h
+++ b/src/activations.h
@@ -1,6 +1,7 @@
-#include "cuda.h"
#ifndef ACTIVATIONS_H
#define ACTIVATIONS_H
+#include "cuda.h"
+#include "math.h"
typedef enum{
LOGISTIC, RELU, RELIE, LINEAR, RAMP, TANH, PLSE
diff --git a/src/cost_layer.c b/src/cost_layer.c
index d2c616f..1ea03bb 100644
--- a/src/cost_layer.c
+++ b/src/cost_layer.c
@@ -38,15 +38,6 @@
return layer;
}
-void pull_cost_layer(cost_layer layer)
-{
- cuda_pull_array(layer.delta_gpu, layer.delta, layer.batch*layer.inputs);
-}
-void push_cost_layer(cost_layer layer)
-{
- cuda_push_array(layer.delta_gpu, layer.delta, layer.batch*layer.inputs);
-}
-
void forward_cost_layer(cost_layer layer, network_state state)
{
if (!state.truth) return;
@@ -63,6 +54,16 @@
#ifdef GPU
+void pull_cost_layer(cost_layer layer)
+{
+ cuda_pull_array(layer.delta_gpu, layer.delta, layer.batch*layer.inputs);
+}
+
+void push_cost_layer(cost_layer layer)
+{
+ cuda_push_array(layer.delta_gpu, layer.delta, layer.batch*layer.inputs);
+}
+
void forward_cost_layer_gpu(cost_layer layer, network_state state)
{
if (!state.truth) return;
diff --git a/src/crop_layer.c b/src/crop_layer.c
index bc13151..e83aea2 100644
--- a/src/crop_layer.c
+++ b/src/crop_layer.c
@@ -37,6 +37,8 @@
int flip = (layer.flip && rand()%2);
int dh = rand()%(layer.h - layer.crop_height + 1);
int dw = rand()%(layer.w - layer.crop_width + 1);
+ float scale = 2;
+ float trans = -1;
if(!state.train){
flip = 0;
dh = (layer.h - layer.crop_height)/2;
@@ -53,7 +55,7 @@
}
row = i + dh;
index = col+layer.w*(row+layer.h*(c + layer.c*b));
- layer.output[count++] = state.input[index];
+ layer.output[count++] = state.input[index]*scale + trans;
}
}
}
diff --git a/src/detection.c b/src/detection.c
index eea6136..024c0e9 100644
--- a/src/detection.c
+++ b/src/detection.c
@@ -203,8 +203,6 @@
fgets(filename, 256, stdin);
strtok(filename, "\n");
image im = load_image_color(filename, im_size, im_size);
- translate_image(im, -128);
- scale_image(im, 1/128.);
printf("%d %d %d\n", im.h, im.w, im.c);
float *X = im.data;
time=clock();
--
Gitblit v1.10.0