From b831db5e58ad37c8f4adf39de7fb5db204209a1c Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Tue, 10 Jan 2017 16:49:38 +0000
Subject: [PATCH] fixed bug: rand() for batches of images

---
 src/data.c     |    6 +++++-
 src/detector.c |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/data.c b/src/data.c
index 8fb1a25..19dca8a 100644
--- a/src/data.c
+++ b/src/data.c
@@ -44,10 +44,12 @@
     char **random_paths = calloc(n, sizeof(char*));
     int i;
     pthread_mutex_lock(&mutex);
+	//printf("n = %d \n", n);
     for(i = 0; i < n; ++i){
-        int index = rand()%m;
+        int index = (rand()*rand())%m;
         random_paths[i] = paths[index];
         //if(i == 0) printf("%s\n", paths[index]);
+		//printf("%s\n", paths[index]);
     }
     pthread_mutex_unlock(&mutex);
     return random_paths;
@@ -714,6 +716,7 @@
 
 void *load_thread(void *ptr)
 {
+	srand(time(0));
     //printf("Loading data: %d\n", rand());
     load_args a = *(struct load_args*)ptr;
     if(a.exposure == 0) a.exposure = 1;
@@ -757,6 +760,7 @@
 
 void *load_threads(void *ptr)
 {
+	srand(time(0));
     int i;
     load_args args = *(load_args *)ptr;
     if (args.threads == 0) args.threads = 1;
diff --git a/src/detector.c b/src/detector.c
index a389407..7535df8 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -78,7 +78,7 @@
     int count = 0;
     //while(i*imgs < N*120){
     while(get_current_batch(net) < net.max_batches){
-        if(l.random && count++%10 == 0){
+		if(l.random && count++%10 == 0){
             printf("Resizing\n");
             int dim = (rand() % 10 + 10) * 32;
             if (get_current_batch(net)+100 > net.max_batches) dim = 544;

--
Gitblit v1.10.0