Skip to content

Commit

Permalink
fixed bug: rand() for batches of images
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Jan 10, 2017
1 parent b593809 commit b831db5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ char **get_random_paths(char **paths, int n, int m)
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;
Expand Down Expand Up @@ -714,6 +716,7 @@ data load_data_detection(int n, char **paths, int m, int w, int h, int boxes, in

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;
Expand Down Expand Up @@ -757,6 +760,7 @@ pthread_t load_data_in_thread(load_args args)

void *load_threads(void *ptr)
{
srand(time(0));
int i;
load_args args = *(load_args *)ptr;
if (args.threads == 0) args.threads = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
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;
Expand Down

0 comments on commit b831db5

Please sign in to comment.