仍在学习 Tensorflow,我正在尝试更改 Darkflow 中某些代码中的损失函数
网络输出形状为 [49,3,2] 的给定张量。我想取张量最后一部分中的两个元素并用一些代码处理它们。然后我想返回数据。所以有点像一张可以与 Tensorflow 一起使用的地图。
更多上下文 -我要更改的文件的https://github.com/thtrieu/darkflow/blob/master/darkflow/net/yolo/train.py 。
所以不确定如何做到这一点,如果我对这个问题不够清楚,请询问更多信息。我仍然试图弄清楚我想做的事情。
例如
S = 7
SS = S * S
C = 8
B = 3
size1 = [None, SS, C]
size2 = [None, SS, B]
# Extract the coordinate prediction from net.out
coords = net_out[:, SS * (C + B):]
# Take flatten array and make it back into a tensor.
coords = tf.reshape(coords, [-1, SS, B, 4])
wh = tf.pow(coords[:,:,:,2:4], 2) * S # unit: grid cell
area_pred = wh[:,:,:,0] * wh[:,:,:,1] # unit: grid cell^2
centers = coords[:,:,:,0:2] # [batch, SS, B, 2]
floor = centers - (wh * .5) # [batch, SS, B, 2]
ceil = centers + (wh * .5) # [batch, SS, B, 2]
# calculate the intersection areas
# WHAT HAPPENS CURRENTLY
intersect_upleft = tf.maximum(floor, _upleft)
intersect_botright = tf.minimum(ceil , _botright)
intersect_wh = intersect_botright - intersect_upleft
intersect_wh = tf.maximum(intersect_wh, 0.0)
intersect = tf.multiply(intersect_wh[:,:,:,0], intersect_wh[:,:,:,1])
# I WANT TO CALCULATE THE AREA OF INTERSECTION THE BOX DIFFERENTLY SO
I WOULD HAVE
MY OWN FUNCTION DOING SOMETHING. BUT I ONLY WANT IT DONE FOR CENTERS
AND THEN RETURN A BIT LIKE A MAP FUNCTION BUT I NEED IT TO WORK WITH
TENSORFLOW PLACEHOLDERS
任何提示或建议都会很好,谢谢家伙:D