标签:box eth nes 方式 依赖 误差 entry cal open
darknet是一个较为轻型的完全基于C与CUDA的开源深度学习框架,其主要特点就是容易安装,没有任何依赖项(OpenCV都可以不用),移植性非常好,支持CPU与GPU两种计算方式。
1、test源码(泛化过程)
(1)test image
a(预测):load_network(network.c) ---> network_predict(network.c) ---> forward_network(network.c) ---> forward_yolo_layer(yolo_layer.c) ----> calc_network_cost(network.c)
b(后处理):get_network_boxes(network.c) ---> make_network_boxes(network.c) ---> fill_network_boxes(network.c)---> get_yolo_detections(yolo_layer.c)
do_nms_sort(box.c) ---> draw_detections(image.c) ---> save_image(image.c)
(2)test 过程中thresh作用
a:get_yolo_detections接口中:
for(n = 0; n < l.n; ++n){
int obj_index = entry_index(l, 0, n*l.w*l.h + i, 4);
float objectness = predictions[obj_index];
if(objectness <= thresh) continue;
int box_index = entry_index(l, 0, n*l.w*l.h + i, 0);
dets[count].bbox = get_yolo_box(predictions, l.biases, l.mask[n], box_index, col, row, l.w, l.h, netw, neth, l.w*l.h);
dets[count].objectness = objectness;
dets[count].classes = l.classes;
for(j = 0; j < l.classes; ++j){
int class_index = entry_index(l, 0, n*l.w*l.h + i, 4 + 1 + j);
float prob = objectness*predictions[class_index];
dets[count].prob[j] = (prob > thresh) ? prob : 0;
}
++count;
}
}
b:draw_detections接口中:
int left = (b.x - b.w / 2.) * im.w;
int right = (b.x + b.w / 2.) * im.w;
int top = (b.y - b.h / 2.) * im.h;
int bot = (b.y + b.h / 2.) * im.h;
2、train源码(训练过程)
(1)根据配置文件解析、创建、配置net的各个层(以卷积层为例),同时配置net的其他参数
load_network(network.c) ---> parse_network_cfg(parser.c)--->parse_convolutional(parser.c) --->make_convolutional_layer(convolutional_layer.c);
注意:make_convolutional_layer过程中特别需要注意以下几个函数指针的配置,分别用来确定前向求损失函数,反向求误差函数,update函数(用来更新参数)
void (*forward) (struct layer, struct network); ---> l.forward = forward_convolutional_layer;
void (*backward) (struct layer, struct network); ---> l.backward = backward_convolutional_layer;
void (*update) (struct layer, update_args); ---> l.update = update_convolutional_layer;
parse_network_cfg(section list node的概念处理配置文件)
总结:该过程最后得到的就是一个根据配置文件创建好的一个net框架, 只差灌入数据
(2)加载数据
load_thread(data.c)--->load_data_detection(data.c)--->fill_truth_detection(data.c 读取图像的标签数据 其他数据集也可以在这里作修改 然后更改路径)
(3)开始训练
train_network(network.c) ---> train_network_datum(network.c 网络训练\前向求损失\反向求误差\最后更新网络参数) --->forward_network (network.c) ---> backward_network (network.c) ---> update_network(network.c) (forward backward update分别使用对应层的函数进行处理)
标签:box eth nes 方式 依赖 误差 entry cal open
原文地址:https://www.cnblogs.com/llfctt/p/9037672.html