Re: [問題] 語法觀念一問
各位前輩,由於問題描述的太過簡略,容小弟詳細說明
其程式碼來自 YOLO 的 predict result decoder,source code 如下 :
netout #為Numpy NDarray
anchors #為 Numpy DNarray
obj_thresh #為 Float32 其數值為 0.6
net_h ,netw #為 int 其數值為 416
def decode_netout(netout, anchors, obj_thresh, net_h, net_w):
grid_h, grid_w = netout.shape[:2]
nb_box = 3
netout = netout.reshape((grid_h, grid_w, nb_box, -1))
nb_class = netout.shape[-1] - 5
boxes = []
netout[..., :2] = _sigmoid(netout[..., :2])
netout[..., 4:] = _sigmoid(netout[..., 4:])
netout[..., 5:] = netout[..., 4][..., np.newaxis] * netout[..., 5:]
netout[..., 5:] *= netout[..., 5:] > obj_thresh
for i in range(grid_h*grid_w):
row = i / grid_w
col = i % grid_w
for b in range(nb_box):
# 4th element is objectness score
objectness = netout[int(row)][int(col)][b][4]
if(objectness.all() <= obj_thresh): continue
# first 4 elements are x, y, w, and h
x, y, w, h = netout[int(row)][int(col)][b][:4]
x = (col + x) / grid_w # center position, unit: image width
y = (row + y) / grid_h # center position, unit: image height
w = anchors[2 * b + 0] * np.exp(w) / net_w # unit: image width
h = anchors[2 * b + 1] * np.exp(h) / net_h # unit: image height
# last elements are class probabilities
classes = netout[int(row)][col][b][5:]
box = BoundBox(x-w/2, y-h/2, x+w/2, y+h/2, objectness, classes)
boxes.append(box)
return boxes
而小弟追蹤該 function 時發現該 objectness 為 float32 (請看截圖) 而無法理解
該ojbectness為何會有 .all() 這個方法, 並且用來判斷 bool ?
一直無法理解這個問題
故上來請教前輩們這個疑惑
謝謝大家幫忙
圖片如下 :
https://photos.app.goo.gl/rbsPt91WBi1FcuvN6
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 117.56.58.151 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1624335041.A.C7D.html
推
06/22 12:25,
2年前
, 1F
06/22 12:25, 1F
→
06/22 12:26,
2年前
, 2F
06/22 12:26, 2F
→
06/22 12:26,
2年前
, 3F
06/22 12:26, 3F
→
06/22 12:27,
2年前
, 4F
06/22 12:27, 4F
→
06/22 12:27,
2年前
, 5F
06/22 12:27, 5F
推
06/22 12:33,
2年前
, 6F
06/22 12:33, 6F
→
06/22 12:33,
2年前
, 7F
06/22 12:33, 7F
→
06/22 12:50,
2年前
, 8F
06/22 12:50, 8F
推
06/22 13:42,
2年前
, 9F
06/22 13:42, 9F
→
06/22 13:43,
2年前
, 10F
06/22 13:43, 10F
→
06/22 13:44,
2年前
, 11F
06/22 13:44, 11F
→
06/22 13:45,
2年前
, 12F
06/22 13:45, 12F
→
06/22 13:49,
2年前
, 13F
06/22 13:49, 13F
推
06/22 15:46,
2年前
, 14F
06/22 15:46, 14F
→
06/22 15:46,
2年前
, 15F
06/22 15:46, 15F
→
06/22 15:48,
2年前
, 16F
06/22 15:48, 16F
推
06/22 16:31,
2年前
, 17F
06/22 16:31, 17F
→
06/22 20:21,
2年前
, 18F
06/22 20:21, 18F
→
06/22 20:29,
2年前
, 19F
06/22 20:29, 19F
→
06/22 20:29,
2年前
, 20F
06/22 20:29, 20F
→
06/23 05:07,
2年前
, 21F
06/23 05:07, 21F
→
06/23 12:34,
2年前
, 22F
06/23 12:34, 22F
討論串 (同標題文章)