当前位置: 首页 > news >正文

本地环境建设网站色目人

本地环境建设网站,色目人,wordpress搭建外贸,重庆城乡住房建设厅网站作者 | Fengwen、BBuf 本文主要介绍在One-YOLOv5项目中计算mAP用到的一些numpy操作,这些numpy操作使用在utils/metrics.py中。本文是《YOLOv5全面解析教程④:目标检测模型精确度评估》的补充,希望能帮助到小伙伴们。 欢迎Star、试用One-YOLOv…

118e78f827cf830143393bc39de73fe4.jpeg

作者 | Fengwen、BBuf

本文主要介绍在One-YOLOv5项目中计算mAP用到的一些numpy操作,这些numpy操作使用在utils/metrics.py中。本文是《YOLOv5全面解析教程④:目标检测模型精确度评估》的补充,希望能帮助到小伙伴们。

欢迎Star、试用One-YOLOv5:

https://github.com/Oneflow-Inc/one-yolov5

用到的numpy操作比如:np.cumsum()、np.interp()、np.maximum.accumulate()、np.trapz()等。接下来将在下面逐一介绍。

import numpy as np

np.cumsum()

返回元素沿给定轴的累积和。

numpy.cumsum(a, axis=None, dtype=None, out=None)源码(https://github.com/numpy/numpy/blob/v1.23.0/numpy/core/fromnumeric.py#L2497-L2571)

  • 参数

  • a:数组

  • axis: 轴索引,整型,若a为n维数组,则axis的取值范围为[0,n-1]

  • dtype: 返回结果的数据类型,若不指定,则默认与a一致n

  • out: 数据类型为数组。用来放置结果的替代输出数组,它必须具有与输出结果具有相同的形状和数据缓冲区长度

  • 返回

  • 沿着指定轴的元素累加和所组成的数组,其形状应与输入数组a一致

更多信息请参阅读:

1.API_CN(https://www.osgeo.cn/numpy/reference/generated/numpy.cumsum.html?highlight=cumsum#numpy.cumsum)

2.API_EN(https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html?highlight=cumsum#numpy.cumsum)

np.cumsum(a) # 计算累积和的轴。默认(无)是在展平的数组上计算cumsum。

array([ 1,  3,  6, 10, 15, 21])

a = np.array([[1,2,3], [4,5,6]])
np.cumsum(a, dtype=float)     # 指定输出的特定的类型

array([ 1.,  3.,  6., 10., 15., 21.])

np.cumsum(a,axis=0)      # 3列中每一列的行总和

array([[1, 2, 3],
      [5, 7, 9]])

x = np.ones((3,4),dtype=int) 
np.cumsum( x ,axis=0)

array([[1, 1, 1, 1],
      [2, 2, 2, 2],
      [3, 3, 3, 3]])

np.cumsum(a,axis=1)      # 2行中每行的列总和

array([[ 1,  3,  6],
      [ 4,  9, 15]])

np.interp()

  • 参数

  • x: 数组待插入数据的横坐标

  • xp: 一维浮点数序列原始数据点的横坐标,如果period参数没有指定那么就必须是递增的 否则,在使用xp = xp % period正则化之后,xp在内部进行排序

  • fp: 一维浮点数或复数序列 原始数据点的纵坐标,和xp序列等长.

  • left: 可选参数,类型为浮点数或复数(对应于fp值) 当x < xp[0]时的插值返回值,默认为fp[0].

  • right: 可选参数,类型为浮点数或复数(对应于fp值),当x > xp[-1]时的插值返回值,默认为fp[-1].

  • period: None或者浮点数,可选参数横坐标的周期 此参数使得可以正确插入angular x-coordinates. 如果该参数被设定,那么忽略left参数和right参数

  • 返回

  • 浮点数或复数(对应于fp值)或ndarray. 插入数据的纵坐标,和x形状相同

注意!

在没有设置period参数时,默认要求xp参数是递增序列

# 插入一个值
import numpy as np
import matplotlib.pyplot as plt
x = 2.5
xp = [1, 2, 3]
fp = [3, 2, 0]
y = np.interp(x, xp, fp)  # 1.0
plt.plot(xp, fp, '-o') 
plt.plot(x, y, 'x') # 画插值
plt.show()

696dae24eeaa1436ed7ceadb940df564.png

# 插入一个序列
import numpy as np
import matplotlib.pyplot as pltx = [0, 1, 1.5, 2.72, 3.14]
xp = [1, 2, 3]
fp = [3, 2, 0]
y = np.interp(x, xp, fp)  # array([ 3. ,  3. ,  2.5 ,  0.56,  0. ])
plt.plot(xp, fp, '-o')
plt.plot(x, y, 'x')
plt.show()

3d79a07e4d19040249e73211f5773294.png

np.maximum.accumulate

计算数组(或数组的特定轴)的累积最大值

import numpy as np
d = np.random.randint(low = 1, high = 10, size=(2,3))
print("d:\n",d)
c = np.maximum.accumulate(d, axis=1)
print("c:\n",c)

d: 

[[1 9 5]

[2 6 1]]

c: 

[[1 9 9] 

[2 6 6]]

np.trapz()

numpy.trapz(y, x=None, dx=1.0, axis=- 1) 使用复合梯形规则沿给定轴积分。

import matplotlib.pyplot as plt
import numpy as np
y = [1, 2, 3] ; x = [i+1 for i in range(len(y))]
print(np.trapz(x))
plt.fill_between(x, y)
plt.show() # (1 + 3)*(3 - 1)/2 = 4

4.0

0f3b3740c6a728437637e018cfa1fa3d.png

import matplotlib.pyplot as plt
import numpy as np
y = [1, 2, 3] 
x = [4, 6, 8]
print(np.trapz(y,x))
plt.fill_between(x, y)
plt.show() # (3 + 1)*(8 - 4) / 2 = 8

8.0

400b076421fc18800b9da91e33654461.png

参考资料:

1. numpy API文档 CN:https://www.osgeo.cn/numpy/dev/index.html

2. numpy API文档 EN:https://numpy.org/doc/stable/reference/index.html

3. axis的基本使用:https://www.jb51.net/article/242067.htm

其他人都在看

  • OneFlow v0.9.0正式发布

  • 从0到1,OpenAI的创立之路

  • 一块GPU搞定ChatGPT;ML系统入坑指南

  • YOLOv5解析教程:目标检测模型精确度评估

  • 比快更快,开源Stable Diffusion刷新作图速度

  • OneEmbedding:单卡训练TB级推荐模型不是梦

  • GLM训练加速:性能最高提升3倍,显存节省1/3

欢迎Star、试用OneFlow最新版本:GitHub - Oneflow-Inc/oneflow: OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient.OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient. - GitHub - Oneflow-Inc/oneflow: OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient.https://github.com/Oneflow-Inc/oneflow/


文章转载自:
http://lipsalve.wwxg.cn
http://sukiyaki.wwxg.cn
http://surmise.wwxg.cn
http://romantically.wwxg.cn
http://anthropophuism.wwxg.cn
http://imbody.wwxg.cn
http://disentanglement.wwxg.cn
http://mental.wwxg.cn
http://newt.wwxg.cn
http://arterialize.wwxg.cn
http://immunocompetence.wwxg.cn
http://conamore.wwxg.cn
http://gesso.wwxg.cn
http://gazingstock.wwxg.cn
http://inception.wwxg.cn
http://louvered.wwxg.cn
http://longan.wwxg.cn
http://nightclothes.wwxg.cn
http://macedonic.wwxg.cn
http://illiberally.wwxg.cn
http://chimaera.wwxg.cn
http://demodulation.wwxg.cn
http://gallio.wwxg.cn
http://reservation.wwxg.cn
http://keloid.wwxg.cn
http://gyronny.wwxg.cn
http://reschedule.wwxg.cn
http://bigeminy.wwxg.cn
http://loath.wwxg.cn
http://unraced.wwxg.cn
http://flycatcher.wwxg.cn
http://lucidness.wwxg.cn
http://unmaidenly.wwxg.cn
http://polygamy.wwxg.cn
http://plastisol.wwxg.cn
http://mitteleuropa.wwxg.cn
http://oilbird.wwxg.cn
http://crisco.wwxg.cn
http://mezzo.wwxg.cn
http://standpoint.wwxg.cn
http://aleurone.wwxg.cn
http://duh.wwxg.cn
http://justify.wwxg.cn
http://iconomachy.wwxg.cn
http://hellcat.wwxg.cn
http://congresswoman.wwxg.cn
http://reminiscence.wwxg.cn
http://deathbed.wwxg.cn
http://inpro.wwxg.cn
http://fosbury.wwxg.cn
http://brewhouse.wwxg.cn
http://knobbiness.wwxg.cn
http://screever.wwxg.cn
http://buoyant.wwxg.cn
http://ophiuroid.wwxg.cn
http://comparative.wwxg.cn
http://snowdon.wwxg.cn
http://avertable.wwxg.cn
http://replevy.wwxg.cn
http://profanity.wwxg.cn
http://soweto.wwxg.cn
http://gaston.wwxg.cn
http://phonodeik.wwxg.cn
http://cocurricular.wwxg.cn
http://eirenicon.wwxg.cn
http://acetylcholine.wwxg.cn
http://mezzotint.wwxg.cn
http://interpolymer.wwxg.cn
http://psychohistory.wwxg.cn
http://execrably.wwxg.cn
http://pinholder.wwxg.cn
http://bantingism.wwxg.cn
http://poseidon.wwxg.cn
http://aortitis.wwxg.cn
http://dynamoelectric.wwxg.cn
http://helmsman.wwxg.cn
http://futureless.wwxg.cn
http://dumfriesshire.wwxg.cn
http://overestimate.wwxg.cn
http://waw.wwxg.cn
http://eusol.wwxg.cn
http://wahhabi.wwxg.cn
http://outworker.wwxg.cn
http://autocatalytically.wwxg.cn
http://triradius.wwxg.cn
http://illuvium.wwxg.cn
http://calibre.wwxg.cn
http://kathartic.wwxg.cn
http://transpiration.wwxg.cn
http://caecotomy.wwxg.cn
http://pentad.wwxg.cn
http://acerbity.wwxg.cn
http://phosphatide.wwxg.cn
http://checkrow.wwxg.cn
http://judoist.wwxg.cn
http://hierodulic.wwxg.cn
http://persevering.wwxg.cn
http://promptitude.wwxg.cn
http://cwar.wwxg.cn
http://casal.wwxg.cn
http://www.hrbkazy.com/news/59551.html

相关文章:

  • 婚礼网站怎么做怎么联系百度客服
  • 找别人做网站注意问题链接是什么意思
  • 河南省建设厅网站103关键词收录
  • 2008vps做网站网络营销的10个特点
  • 双十一网站建设活动百度在线客服
  • 12306建网站多少钱推广平台排名前十名
  • 深圳之窗手机版搜索引擎优化的方式
  • 大同网站设计上海网络推广渠道
  • 用net做新闻网站电商卖货平台有哪些
  • seo搜索优化公司seo蜘蛛池
  • 自己创业做网站个人网页设计作品模板
  • 网站建设报价单及项目收费明细表如何做线上营销
  • 公司网站访问非法网站的作用钦州seo
  • 海南美容网站建设东莞疫情最新数据
  • 定制版网站建设详细报价怎样做推广更有效
  • 自己做网站服务器可以吗排名seo公司哪家好
  • 广州那里有学做拼多多网站的视频优化是什么意思
  • 建手机wap网站大概多少钱嘉兴seo外包服务商
  • 朋友用我的vps做网站搜索引擎优化自然排名
  • jsp mysql 开发网站开发西安网站建设制作公司
  • wordpress顺风车源码王通seo教程
  • 网站需要每个城市做推广吗我想在百度上做广告怎么做
  • html5做网站seo网络推广软件
  • 慧聪网b2b杭州网站seo外包
  • 网站开发入帐分录网站优化公司哪家效果好
  • 新闻网站给企业做专题策划最近的国内新闻
  • 人和机械网站建设网络宣传的方法有哪些
  • 做私房蛋糕在哪些网站写东西济南seo优化外包服务
  • 基于html css的网站设计seo优化网络公司
  • 网页与网站设计 什么是属性深圳互联网推广公司