MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / train_super

Function train_super

yolo_detector/darknet_opt/examples/super.c:3–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "darknet.h"
2
3void train_super(char *cfgfile, char *weightfile, int clear)
4{
5 char *train_images = "/data/imagenet/imagenet1k.train.list";
6 char *backup_directory = "/home/pjreddie/backup/";
7 srand(time(0));
8 char *base = basecfg(cfgfile);
9 printf("%s\n", base);
10 float avg_loss = -1;
11 network *net = load_network(cfgfile, weightfile, clear);
12 printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
13 int imgs = net->batch*net->subdivisions;
14 int i = *net->seen/imgs;
15 data train, buffer;
16
17
18 list *plist = get_paths(train_images);
19 //int N = plist->size;
20 char **paths = (char **)list_to_array(plist);
21
22 load_args args = {0};
23 args.w = net->w;
24 args.h = net->h;
25 args.scale = 4;
26 args.paths = paths;
27 args.n = imgs;
28 args.m = plist->size;
29 args.d = &buffer;
30 args.type = SUPER_DATA;
31
32 pthread_t load_thread = load_data_in_thread(args);
33 clock_t time;
34 //while(i*imgs < N*120){
35 while(get_current_batch(net) < net->max_batches){
36 i += 1;
37 time=clock();
38 pthread_join(load_thread, 0);
39 train = buffer;
40 load_thread = load_data_in_thread(args);
41
42 printf("Loaded: %lf seconds\n", sec(clock()-time));
43
44 time=clock();
45 float loss = train_network(net, train);
46 if (avg_loss < 0) avg_loss = loss;
47 avg_loss = avg_loss*.9 + loss*.1;
48
49 printf("%d: %f, %f avg, %f rate, %lf seconds, %d images\n", i, loss, avg_loss, get_current_rate(net), sec(clock()-time), i*imgs);
50 if(i%1000==0){
51 char buff[256];
52 sprintf(buff, "%s/%s_%d.weights", backup_directory, base, i);
53 save_weights(net, buff);
54 }
55 if(i%100==0){
56 char buff[256];
57 sprintf(buff, "%s/%s.backup", backup_directory, base);
58 save_weights(net, buff);
59 }
60 free_data(train);

Callers 1

run_superFunction · 0.85

Calls 12

timeFunction · 0.85
basecfgFunction · 0.85
load_networkFunction · 0.85
get_pathsFunction · 0.85
list_to_arrayFunction · 0.85
load_data_in_threadFunction · 0.85
get_current_batchFunction · 0.85
secFunction · 0.85
train_networkFunction · 0.85
get_current_rateFunction · 0.85
save_weightsFunction · 0.85
free_dataFunction · 0.85

Tested by

no test coverage detected