From 8f1b4e0962857d402f9d017fcbf387ef0eceb7c4 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 01 Sep 2016 23:48:41 +0000
Subject: [PATCH] updates and things
---
src/cost_layer.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/cost_layer.c b/src/cost_layer.c
index fdba777..0d8cb8c 100644
--- a/src/cost_layer.c
+++ b/src/cost_layer.c
@@ -98,6 +98,15 @@
cuda_push_array(l.delta_gpu, l.delta, l.batch*l.inputs);
}
+int float_abs_compare (const void * a, const void * b)
+{
+ float fa = *(const float*) a;
+ if(fa < 0) fa = -fa;
+ float fb = *(const float*) b;
+ if(fb < 0) fb = -fb;
+ return (fa > fb) - (fa < fb);
+}
+
void forward_cost_layer_gpu(cost_layer l, network_state state)
{
if (!state.truth) return;
@@ -111,6 +120,16 @@
l2_gpu(l.batch*l.inputs, state.input, state.truth, l.delta_gpu, l.output_gpu);
}
+ if(l.ratio){
+ cuda_pull_array(l.delta_gpu, l.delta, l.batch*l.inputs);
+ qsort(l.delta, l.batch*l.inputs, sizeof(float), float_abs_compare);
+ int n = (1-l.ratio) * l.batch*l.inputs;
+ float thresh = l.delta[n];
+ thresh = 0;
+ printf("%f\n", thresh);
+ supp_ongpu(l.batch*l.inputs, thresh, l.delta_gpu, 1);
+ }
+
cuda_pull_array(l.output_gpu, l.output, l.batch*l.inputs);
l.cost[0] = sum_array(l.output, l.batch*l.inputs);
}
--
Gitblit v1.10.0