mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
hm
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
[net]
|
[net]
|
||||||
batch=64
|
batch=128
|
||||||
subdivisions=1
|
subdivisions=2
|
||||||
height=256
|
height=256
|
||||||
width=256
|
width=256
|
||||||
channels=3
|
channels=3
|
||||||
learning_rate=0.00001
|
learning_rate=0.0000001
|
||||||
momentum=0.9
|
momentum=0.9
|
||||||
decay=0.0005
|
decay=0.0005
|
||||||
seen=0
|
seen=0
|
||||||
@ -40,7 +40,7 @@ activation=ramp
|
|||||||
|
|
||||||
[convolutional]
|
[convolutional]
|
||||||
filters=1
|
filters=1
|
||||||
size=5
|
size=3
|
||||||
stride=1
|
stride=1
|
||||||
pad=1
|
pad=1
|
||||||
activation=logistic
|
activation=logistic
|
||||||
|
@ -553,6 +553,8 @@ void *load_thread(void *ptr)
|
|||||||
*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h);
|
*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h);
|
||||||
} else if (a.type == DETECTION_DATA){
|
} else if (a.type == DETECTION_DATA){
|
||||||
*a.d = load_data_detection(a.n, a.paths, a.m, a.classes, a.w, a.h, a.num_boxes, a.background);
|
*a.d = load_data_detection(a.n, a.paths, a.m, a.classes, a.w, a.h, a.num_boxes, a.background);
|
||||||
|
} else if (a.type == WRITING_DATA){
|
||||||
|
*a.d = load_data_writing(a.paths, a.n, a.m, a.w, a.h, a.downsample);
|
||||||
} else if (a.type == REGION_DATA){
|
} else if (a.type == REGION_DATA){
|
||||||
*a.d = load_data_region(a.n, a.paths, a.m, a.w, a.h, a.num_boxes, a.classes);
|
*a.d = load_data_region(a.n, a.paths, a.m, a.w, a.h, a.num_boxes, a.classes);
|
||||||
} else if (a.type == COMPARE_DATA){
|
} else if (a.type == COMPARE_DATA){
|
||||||
|
@ -26,7 +26,7 @@ typedef struct{
|
|||||||
} data;
|
} data;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CLASSIFICATION_DATA, DETECTION_DATA, CAPTCHA_DATA, REGION_DATA, IMAGE_DATA, COMPARE_DATA
|
CLASSIFICATION_DATA, DETECTION_DATA, CAPTCHA_DATA, REGION_DATA, IMAGE_DATA, COMPARE_DATA, WRITING_DATA
|
||||||
} data_type;
|
} data_type;
|
||||||
|
|
||||||
typedef struct load_args{
|
typedef struct load_args{
|
||||||
@ -37,6 +37,7 @@ typedef struct load_args{
|
|||||||
char **labels;
|
char **labels;
|
||||||
int h;
|
int h;
|
||||||
int w;
|
int w;
|
||||||
|
int downsample;
|
||||||
int nh;
|
int nh;
|
||||||
int nw;
|
int nw;
|
||||||
int num_boxes;
|
int num_boxes;
|
||||||
|
@ -19,17 +19,34 @@ void train_writing(char *cfgfile, char *weightfile)
|
|||||||
load_weights(&net, weightfile);
|
load_weights(&net, weightfile);
|
||||||
}
|
}
|
||||||
printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||||
int imgs = 1024;
|
int imgs = net.batch*net.subdivisions;
|
||||||
int i = *net.seen/imgs;
|
|
||||||
list *plist = get_paths("figures.list");
|
list *plist = get_paths("figures.list");
|
||||||
char **paths = (char **)list_to_array(plist);
|
char **paths = (char **)list_to_array(plist);
|
||||||
printf("%d\n", plist->size);
|
|
||||||
clock_t time;
|
clock_t time;
|
||||||
while(1){
|
int N = plist->size;
|
||||||
++i;
|
printf("N: %d\n", N);
|
||||||
|
|
||||||
|
data train, buffer;
|
||||||
|
|
||||||
|
load_args args = {0};
|
||||||
|
args.w = net.w;
|
||||||
|
args.h = net.h;
|
||||||
|
args.paths = paths;
|
||||||
|
args.n = imgs;
|
||||||
|
args.m = N;
|
||||||
|
args.downsample = 1;
|
||||||
|
args.d = &buffer;
|
||||||
|
args.type = WRITING_DATA;
|
||||||
|
|
||||||
|
pthread_t load_thread = load_data_in_thread(args);
|
||||||
|
int epoch = (*net.seen)/N;
|
||||||
|
while(get_current_batch(net) < net.max_batches || net.max_batches == 0){
|
||||||
time=clock();
|
time=clock();
|
||||||
data train = load_data_writing(paths, imgs, plist->size, 256, 256, 1);
|
pthread_join(load_thread, 0);
|
||||||
|
train = buffer;
|
||||||
|
load_thread = load_data_in_thread(args);
|
||||||
printf("Loaded %lf seconds\n",sec(clock()-time));
|
printf("Loaded %lf seconds\n",sec(clock()-time));
|
||||||
|
|
||||||
time=clock();
|
time=clock();
|
||||||
float loss = train_network(net, train);
|
float loss = train_network(net, train);
|
||||||
|
|
||||||
@ -51,13 +68,15 @@ void train_writing(char *cfgfile, char *weightfile)
|
|||||||
|
|
||||||
if(avg_loss == -1) avg_loss = loss;
|
if(avg_loss == -1) avg_loss = loss;
|
||||||
avg_loss = avg_loss*.9 + loss*.1;
|
avg_loss = avg_loss*.9 + loss*.1;
|
||||||
printf("%d: %f, %f avg, %lf seconds, %d images\n", i, loss, avg_loss, sec(clock()-time), *net.seen);
|
printf("%d, %.3f: %f, %f avg, %f rate, %lf seconds, %d images\n", get_current_batch(net), (float)(*net.seen)/N, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net.seen);
|
||||||
free_data(train);
|
free_data(train);
|
||||||
//if(i%100 == 0 && net.learning_rate > .00001) net.learning_rate *= .97;
|
if(*net.seen/N > epoch){
|
||||||
if(i%1000==0){
|
epoch = *net.seen/N;
|
||||||
char buff[256];
|
char buff[256];
|
||||||
sprintf(buff, "%s/%s_%d.weights", backup_directory, base, i);
|
sprintf(buff, "%s/%s_%d.weights",backup_directory,base, epoch);
|
||||||
save_weights(net, buff);
|
//TODO
|
||||||
|
if(get_current_batch(net)%10 == 0)
|
||||||
|
save_weights(net, buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user