numpy
页页读
这个作者很懒,什么都没留下…
展开
-
【python】numpy数组的维度增减方法
使用np.expand_dims()为数组增加指定的轴,np.squeeze()将数组中的轴进行压缩减小维度。1.增加numpy array的维度在操作数组情况下,需要按照某个轴将不同数组的维度对齐,这时候需要为数组添加维度(特别是将二维数组变成高维张量的情况下)。numpy提供了expand_dims()函数来为数组增加维度:import numpy as npa = np.array([[1,2],[3,4]])a.shapeprint(a)>>>"""(2L,.转载 2020-08-25 12:29:16 · 6351 阅读 · 0 评论 -
使用numpy实现nms
"""基于numpy 实现的 非极大值抑制 NMS"""import numpy as npdef py_cpu_nms(dets, thresh): """ nms :param dets: ndarray [x1,y1,x2,y2,score] :param thresh: int :return: list[index] """ x1 = dets[:, 0] y1 = dets[:, 1] x2 = dets[:,转载 2020-08-21 18:34:36 · 641 阅读 · 0 评论 -
np.argsort() 与 array.argsort()
两者都是numpy的使用。都是先排序(默认从小到大),而后返回排序后个元素在原数组的索引。具体使用请看一下实验:一维数组>>> import numpy as np>>> a = np.array([3,5,2,6,7])>>> np.argsort(a, axis=0) # 第一种方式array([2, 0, 1, 3, 4], dtype=int64)>>> a.argsort() # 第二种方式array原创 2020-08-21 18:32:01 · 803 阅读 · 0 评论