Python 板


LINE

各位前辈,由於问题描述的太过简略,容小弟详细说明 其程式码来自 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://webptt.com/cn.aspx?n=bbs/Python/M.1624335041.A.C7D.html
1F:推 penut85420: 我在想你的那个float32应该是来自numpy.float32 06/22 12:25
2F:→ penut85420: 我观察前面的变数名称只有显示ndarray 06/22 12:26
3F:→ penut85420: 而不是numpy.ndarray 06/22 12:26
4F:→ penut85420: 所以我推测了这个float32应该是numpy.float32 06/22 12:27
5F:→ penut85420: 而numpy.float32也确实有.all()这个方法 06/22 12:27
6F:推 penut85420: 关於bool判断,我在GitHub上找到一个Issue也在谈论 06/22 12:33
7F:→ penut85420: https://git.io/Jn14v 06/22 12:33
8F:→ chengreg: 是的。该文的问题跟小弟的一模一样 谢谢前辈 06/22 12:50
9F:推 s0914714: 所以你上篇回应不太精准 这就是numpy的东西 06/22 13:42
10F:→ s0914714: 一般大家讲的Python指的是原生的Python 06/22 13:43
11F:→ chengreg: 这也是小弟头痛的地方,有时候会搞不清楚该数值从何而来 06/22 13:44
12F:→ chengreg: 但经由penut前辈小弟找到issue并且该作者说这是一个bug 06/22 13:45
13F:→ chengreg: 该bug也已修正,小弟会再多注意是否研读新版本,谢谢大家 06/22 13:49
14F:推 poototo: IDE 好像都不会显示更多,是numpy的float32没错 06/22 15:46
15F:→ poototo: x = np.float32(-1) 可以用x.all() 06/22 15:46
16F:→ poototo: array.item(n) 跟 array[n] 回传的类型也不一样喔 06/22 15:48
17F:推 penut85420: 我推荐检测特定变数的型态还是用内建的type()比较好 06/22 16:31
18F:→ chengreg: 谢谢前辈提供经验! 06/22 20:21
19F:→ chengreg: 该问题小弟已全数了解并成功解决 06/22 20:29
20F:→ chengreg: 再次谢谢各位前辈! 06/22 20:29
21F:→ RumiManiac: 原生型别也不是叫做 float32 啊... 06/23 05:07
22F:→ chengreg: 是。我会多注意行型别的。谢谢前辈提醒 06/23 12:34







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP