From d1d56a2a72247ef080eb124ce6605f3218ce4295 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 10 Jul 2015 23:38:07 +0000
Subject: [PATCH] Added alexnet cfg

---
 src/utils.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/utils.c b/src/utils.c
index 6fb0e43..63664ec 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -18,8 +18,6 @@
         c = next+1;
     }
     c = copy_string(c);
-    next = strchr(c, '_');
-    if (next) *next = 0;
     next = strchr(c, '.');
     if (next) *next = 0;
     return c;
@@ -73,11 +71,11 @@
 void top_k(float *a, int n, int k, int *index)
 {
     int i,j;
-    for(j = 0; j < k; ++j) index[j] = 0;
+    for(j = 0; j < k; ++j) index[j] = -1;
     for(i = 0; i < n; ++i){
         int curr = i;
         for(j = 0; j < k; ++j){
-            if(a[curr] > a[index[j]]){
+            if((index[j] < 0) || a[curr] > a[index[j]]){
                 int swap = curr;
                 curr = index[j];
                 index[j] = swap;
@@ -276,10 +274,10 @@
     return variance;
 }
 
-float constrain(float a, float max)
+float constrain(float min, float max, float a)
 {
-    if(a > abs(max)) return abs(max);
-    if(a < -abs(max)) return -abs(max);
+    if (a < min) return min;
+    if (a > max) return max;
     return a;
 }
 

--
Gitblit v1.10.0