【发布时间】:2019-05-08 02:15:39
【问题描述】:
我阅读了yolov2的实现。我对它的损失有一些疑问。下面是损失函数的伪代码,希望我做对了。
costs = np.zeros(output.shape)
for pred_box in all prediction box:
if (max iou pred_box has with all truth box < threshold):
costs[pred_box][obj] = (sigmoid(obj)-0)^2 * 1
else:
costs[pred_box][obj] = 0
costs[pred_box][x] = (sigmoid(x)-0.5)^2 * 0.01
costs[pred_box][y] = (sigmoid(y)-0.5)^2 * 0.01
costs[pred_box][w] = (w-0)^2 * 0.01
costs[pred_box][h] = (h-0)^2 * 0.01
for truth_box all ground truth box:
pred_box = the one prediction box that is supposed to predict for truth_box
costs[pred_box][obj] = (1-sigmoid(obj))^2 * 5
costs[pred_box][x] = (sigmoid(x)-truex)^2 * (2- truew*trueh/imagew*imageh)
costs[pred_box][y] = (sigmoid(y)-truey)^2 * (2- truew*trueh/imagew*imageh)
costs[pred_box][w] = (w-log(truew/anchorw))^2 * (2- truew*trueh/imagew*imageh)
costs[pred_box][h] = (h-log(trueh/anchorh))^2 * (2- truew*trueh/imagew*imageh)
costs[pred_box][classes] = softmax_euclidean
total loss = sum(costs)
我对此有一些疑问:
1. 代码每 10 批随机将训练图像的尺寸调整为 320 到 608 之间的尺寸,但锚框没有相应调整大小。为什么不调整锚尺寸。我的意思是你选择了一组最常见的锚在 13*13 的特征图中,这些锚点在 19*19 的特征图中并不常见,所以为什么不根据图像大小调整锚点的大小。
2. 对未分配真值的框的 x,y,w,h 预测应用成本,这会促使 w,h 完全适合锚点,默认情况下 x,y 会在单元格中居中,很有帮助以及为什么会这样。为什么不将位置预测成本仅应用于分配了事实的那些,而忽略未分配的那些。
3. 为什么不简单地应用 (obj-0)^2 作为所有未分配真值的框的 obj 预测成本。在 yolov2 中,对未分配真值的框的 obj 预测并非全部应用成本,只有那些没有分配真值的框分配的真理与所有真理没有太多重叠,并且是应用成本。为什么会这样,很复杂。
【问题讨论】:
标签: python machine-learning yolo darknet