一、 numpy:
a=np.random.random((0,3))
b=np.random.randint(0,10,size=[3,3])
1.2 all any:
(a==b).all(),比对a矩阵和b的所有对应的元素是否相等
(a==b).any(),比对a矩阵和b是否有一个对应元素相等。
事实上,all()操作就是对两个矩阵的比对结果再做一次与运算,而any则是做一次或运算
1.3 np.newaxis np.hstack的使用:
def _mkanchors(ws, hs, x_ctr, y_ctr): """ Given a vector of widths (ws) and heights (hs) around a center (x_ctr, y_ctr), output a set of anchors (windows). """ ws = ws[:, np.newaxis] hs = hs[:, np.newaxis] anchors = np.hstack((x_ctr - 0.5 * (ws - 1), y_ctr - 0.5 * (hs - 1), x_ctr + 0.5 * (ws - 1), y_ctr + 0.5 * (hs - 1))) return anchors
来自rgb大神py-faster-rcnn