Fix: Correct calculation of training time remaininig when resume training (src/classifier.c)

Output training time remaining to console if darknet is not compiled with OpenCV
pull/4976/head
Muhammad Maaz 5 years ago
parent 8800212faa
commit 9407a81c9d
  1. 18
      src/classifier.c

@ -136,7 +136,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
float topk = 0;
int count = 0;
double start, time_remaining, avg_t_minus_1, avg_t, alpha = 0.01;
double start, time_remaining, avg_time = -1, alpha_time = 0.01;
start = what_time_is_it_now();
while(get_current_batch(net) < net.max_batches || net.max_batches == 0){
@ -187,18 +187,14 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
draw_precision = 1;
}
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
time_remaining = (net.max_batches - i)*(what_time_is_it_now() - start) / 60 / 60;
if (i > 1){ // ignore the first iteration
if (i == 2){
avg_t_minus_1 = time_remaining;
}
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, avg_t);
// set initial value, even if resume training from 10000 iteration
if (avg_time < 0) avg_time = time_remaining;
else avg_time = alpha_time * time_remaining + (1 - alpha_time) * avg_time;
start = what_time_is_it_now();
printf("%d, %.3f: %f, %f avg, %f rate, %lf seconds, %ld images, %f time left\n", get_current_batch(net), (float)(*net.seen)/ train_images_num, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net.seen, avg_time);
#ifdef OPENCV
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_time);
#endif // OPENCV
if (i >= (iter_save + 1000)) {

Loading…
Cancel
Save