Logic Change: Implements rolling avg for remaining time calculation in classifier.c

pull/4976/head
Muhammad Maaz 5 years ago
parent b77add049e
commit d6253d5cd7
  1. 17
      src/classifier.c

@ -133,7 +133,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
float topk = 0; float topk = 0;
int count = 0; int count = 0;
double start, end, tmp, time_remaining[1000] = {0}; double start, end, time_remaining, avg_t_minus_1, avg_t, alpha = 0.01;
start = what_time_is_it_now(); start = what_time_is_it_now();
while(get_current_batch(net) < net.max_batches || net.max_batches == 0){ while(get_current_batch(net) < net.max_batches || net.max_batches == 0){
@ -187,16 +187,15 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
printf("%d, %.3f: %f, %f avg, %f rate, %lf seconds, %ld images\n", get_current_batch(net), (float)(*net.seen)/ train_images_num, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net.seen); printf("%d, %.3f: %f, %f avg, %f rate, %lf seconds, %ld images\n", get_current_batch(net), (float)(*net.seen)/ train_images_num, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net.seen);
#ifdef OPENCV #ifdef OPENCV
end = what_time_is_it_now(); end = what_time_is_it_now();
time_remaining[i%1000] = (net.max_batches - i)*(end - start) / 60 / 60; time_remaining = (net.max_batches - i)*(end - start) / 60 / 60;
tmp = 0.0; if (i > 1){ // ignore the first iteration
int j, count = 0; if (i == 2){
for (j = 0; j < 1000; ++j){ avg_t_minus_1 = time_remaining;
if (time_remaining[j] != 0){
tmp += time_remaining[j];
count++;
} }
avg_t = alpha * time_remaining + (1 - alpha) * avg_t_minus_1;
avg_t_minus_1 = avg_t;
} }
if (!dontuse_opencv) draw_train_loss(windows_name, img, img_size, avg_loss, max_img_loss, i, net.max_batches, topk, draw_precision, topk_buff, dont_show, mjpeg_port, tmp/count); if (!dontuse_opencv) draw_train_loss(windows_name, img, img_size, avg_loss, max_img_loss, i, net.max_batches, topk, draw_precision, topk_buff, dont_show, mjpeg_port, avg_t);
start = what_time_is_it_now(); start = what_time_is_it_now();
#endif // OPENCV #endif // OPENCV

Loading…
Cancel
Save