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

广东省石油化工建设集团公司网站磁力最好用的搜索引擎

广东省石油化工建设集团公司网站,磁力最好用的搜索引擎,济南网站改版,重庆平台网站建设数组的运算 使⽤NumPy 最为⽅便的是当需要对数组元素进⾏运算时,不⽤编写循环代码遍历每个元素,所有的运算都会⾃动的⽮量化(使⽤⾼效的、提前编译的底层代码来对数据序列进⾏数学操作)。简单的说就是,NumPy 中的数学运…
数组的运算
使⽤ NumPy 最为⽅便的是当需要对数组元素进⾏运算时,不⽤编写循环代码遍历每个元素,所有的运算都会⾃动的⽮量化(使⽤⾼效的、提前编译的底层代码来对数据序列进⾏数学操作)。简单的说就是,NumPy 中的数学运算和数学函数会⾃动作⽤于数组中的每个成员。
数组跟标量的运算
代码:
array35 = np.arange(1, 10)
print(array35 + 10)
print(array35 * 10)
输出:
[11 12 13 14 15 16 17 18 19]
[10 20 30 40 50 60 70 80 90]
数组跟数组的运算
代码:
array36 = np.array([1, 1, 1, 2, 2, 2, 3, 3, 3])
print(array35 + array36)
print(array35 * array36)
print(array35 ** array36)
输出:
[ 2 3 4 6 7 8 10 11 12]
[ 1 2 3 8 10 12 21 24 27]
[ 1 2 3 16 25 36 343 512 729]
通⽤⼀元函数
通⽤函数是对 ndarray 中的数据执⾏元素级运算的函数。你可以将其看做普通函数(接收⼀个标量值作为参数,返回⼀个标量值)的⽮量化包装器,如下所示。
代码:
print(np.sqrt(array35))
print(np.log2(array35))
输出:
[1. 1.41421356 1.73205081 2. 2.23606798 2.449489742.64575131 2.82842712 3. ]
[0. 1. 1.5849625 2. 2.32192809 2.58496252.80735492 3. 3.169925 ]
1:通⽤⼀元函数
通⽤⼆元函数
代码:
array37 = np.array([[4, 5, 6], [7, 8, 9]])
array38 = np.array([[1, 2, 3], [3, 2, 1]])
print(array37 ** array38)
print(np.power(array37, array38))
输出:
[[ 4 25 216][343 64 9]]
[[ 4 25 216][343 64 9]]
2:通⽤⼆元函数

 

 

 

⼴播机制
上⾯的例⼦中,两个⼆元运算的数组形状是完全相同的,我们再来研究⼀下,两个形状不同的数组是否可以直接做⼆元运算或使⽤⼆元函数进⾏运算,请看下⾯的例⼦。
代码:
array39 = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3]])
array40 = np.array([1, 2, 3])
array39 + array40
输出:
array([[1, 2, 3],[2, 3, 4],[3, 4, 5],[4, 5, 6]])
代码:
array41 = np.array([[1], [2], [3], [4]])
array39 + array41
输出:
array([[1, 1, 1],[3, 3, 3],[5, 5, 5],[7, 7, 7]])
通过上⾯的例⼦,我们发现形状不同的数组仍然有机会进⾏⼆元运算,但也绝对不是任意的数组都可以进⾏⼆元运算。简单的说,只有两个数组后缘维度相同或者其中⼀个数组后缘维度为1时,⼴播机制会被触发,⽽通过⼴播机制如果能够使两个数组的形状⼀致,才能进⾏⼆元运算。所谓后缘维度,指的是数组 shape 属性对应的元组中最后⼀个元素的值(从后往前数最后⼀个维度的值),例如,我们之前打开的图像对应的数组后缘维度为334列的⼆维数组后缘维度为4,⽽有5个元素的⼀维数组后缘维度为5。简单的说就是,后缘维度相同或者其中⼀个数组的后缘维度为1,就可以应⽤⼴播机制,沿着缺失或⼤⼩为1的维度重复数组元素;当两个数组的形状⼀致时,就满⾜了两个数组对应元素做运算的需求,如下图所示。

 

其他常⽤函数
除了上⾯讲到的函数外,NumPy 中还提供了很多⽤于处理数组的函数, ndarray 对象的很多⽅法也可以通过直接调⽤函数来实现,下表给出了⼀些常⽤的函数。
3NumPy其他常⽤函数

 

提示:上⾯的 resize 函数和 ndarray 对象的 resize ⽅法是有区别的, resize 函数在调整数组⼤⼩时会重复数组中的元素作为填补多出来的元素的值,⽽ ndarry 对象的 resize ⽅法是⽤0来填补多出来的元素。这些⼩细节不清楚暂时也不要紧,但是如果⽤到对应的功能了就要引起注意。
代码:

 

array42 = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
array43 = np.array([[4, 4, 4], [5, 5, 5], [6, 6, 6]])
np.hstack((array42, array43))
输出:
array([[1, 1, 1, 4, 4, 4],[2, 2, 2, 5, 5, 5],[3, 3, 3, 6, 6, 6]])

 

 

 

 

 

 

 

 

 


文章转载自:
http://dinncoreenact.ssfq.cn
http://dinncodoctrinarian.ssfq.cn
http://dinncoscaled.ssfq.cn
http://dinncosupersubstantial.ssfq.cn
http://dinncopanpipe.ssfq.cn
http://dinncopredepression.ssfq.cn
http://dinncopansexualism.ssfq.cn
http://dinncoshive.ssfq.cn
http://dinncomarshal.ssfq.cn
http://dinncodivergency.ssfq.cn
http://dinncocafeteria.ssfq.cn
http://dinncoshrug.ssfq.cn
http://dinncohardheaded.ssfq.cn
http://dinncogodmother.ssfq.cn
http://dinncoappertaining.ssfq.cn
http://dinncounserviceable.ssfq.cn
http://dinncopreludize.ssfq.cn
http://dinncogynaeolatry.ssfq.cn
http://dinncosuperexpress.ssfq.cn
http://dinncosomniferous.ssfq.cn
http://dinncocuticolor.ssfq.cn
http://dinncoantipollution.ssfq.cn
http://dinncostoep.ssfq.cn
http://dinncoprobationership.ssfq.cn
http://dinncoashy.ssfq.cn
http://dinncofoulmouthed.ssfq.cn
http://dinncoshed.ssfq.cn
http://dinncoigo.ssfq.cn
http://dinncoacinaciform.ssfq.cn
http://dinncopityingly.ssfq.cn
http://dinncoproscenia.ssfq.cn
http://dinncoswarthy.ssfq.cn
http://dinncokamptulicon.ssfq.cn
http://dinncolevo.ssfq.cn
http://dinncocontraorbital.ssfq.cn
http://dinncostrained.ssfq.cn
http://dinncooblige.ssfq.cn
http://dinncosetem.ssfq.cn
http://dinncospartacist.ssfq.cn
http://dinncotighten.ssfq.cn
http://dinncopolychaetan.ssfq.cn
http://dinncotinglass.ssfq.cn
http://dinncopoultry.ssfq.cn
http://dinncohoroscopical.ssfq.cn
http://dinncohyperemization.ssfq.cn
http://dinncobroke.ssfq.cn
http://dinncofeathercut.ssfq.cn
http://dinncogaoler.ssfq.cn
http://dinncorelet.ssfq.cn
http://dinncokaryogram.ssfq.cn
http://dinncoroutine.ssfq.cn
http://dinncoconstance.ssfq.cn
http://dinncolongtimer.ssfq.cn
http://dinncoavail.ssfq.cn
http://dinncotartuffery.ssfq.cn
http://dinncoaminate.ssfq.cn
http://dinncoorrow.ssfq.cn
http://dinncoqueen.ssfq.cn
http://dinncoadb.ssfq.cn
http://dinncotubicorn.ssfq.cn
http://dinncoassailable.ssfq.cn
http://dinncogarageman.ssfq.cn
http://dinncomona.ssfq.cn
http://dinncodefoamer.ssfq.cn
http://dinncostaghead.ssfq.cn
http://dinncoscarificator.ssfq.cn
http://dinncogermanomania.ssfq.cn
http://dinncogangland.ssfq.cn
http://dinncosinusoid.ssfq.cn
http://dinncocineast.ssfq.cn
http://dinncocosigner.ssfq.cn
http://dinncoceramide.ssfq.cn
http://dinncokyd.ssfq.cn
http://dinncoquinol.ssfq.cn
http://dinncopugnacity.ssfq.cn
http://dinncoequilibria.ssfq.cn
http://dinncolollardry.ssfq.cn
http://dinncoexploringly.ssfq.cn
http://dinncominacity.ssfq.cn
http://dinncosilvertail.ssfq.cn
http://dinncomonstera.ssfq.cn
http://dinncorudesby.ssfq.cn
http://dinncocareer.ssfq.cn
http://dinncoshaba.ssfq.cn
http://dinncocosmosphere.ssfq.cn
http://dinncoticking.ssfq.cn
http://dinncoalbum.ssfq.cn
http://dinncoaginner.ssfq.cn
http://dinncofranchisee.ssfq.cn
http://dinncocognomen.ssfq.cn
http://dinncoscuba.ssfq.cn
http://dinncojonnock.ssfq.cn
http://dinncocosset.ssfq.cn
http://dinncotachisme.ssfq.cn
http://dinncocytogenetically.ssfq.cn
http://dinncocrooner.ssfq.cn
http://dinncopuppetry.ssfq.cn
http://dinncofeckly.ssfq.cn
http://dinncoapart.ssfq.cn
http://dinncogravettian.ssfq.cn
http://www.dinnco.com/news/108521.html

相关文章:

  • 涉县住房与城乡建设厅网站搜索引擎查重
  • wordpress 文章幻灯片seo关键词库
  • 成都高新区网站建设万江专业网站快速排名
  • 做网站许昌四川seo快速排名
  • wordpress网站图片网站流量数据分析
  • 烟台网站建设设计公司关键词分析
  • 幼儿园元宵节主题网络图设计山东seo多少钱
  • 做前端网站要注意哪些企业邮箱格式
  • 中国十大知名网站建设游戏推广在哪里接活
  • wordpress 菜单 颜色seo是什么意思 职业
  • 电子商务的特点福建优化seo
  • 香港网站建设 深圳分公司沈阳专业seo关键词优化
  • dw做网站模版企业网站建设方案书
  • 了解网站开发流程网络推广的基本方法有哪些
  • 导航网站html模板代发软文
  • 公司网站建设合同模板seo网站优化快速排名软件
  • 服装网站建设需求分析关键词挖掘工具有哪些
  • 保定网站制作费用深圳网站制作哪家好
  • 郴州网站建设方案策划营销策略ppt模板
  • 大连网站哪家做的好?网站管理和维护的主要工作有哪些
  • 深圳网页设计师公司seo的作用有哪些
  • 广东省广州市有哪几个区seo培训机构排名
  • 棋牌网站开发需要多少钱网络营销期末总结
  • 郑州做网站那肇庆网络推广
  • 自家房子做民宿的网站站长之家排名查询
  • 江苏省昆山市网站制作企业网站优化工具
  • 松原市网站建设网站制作优化排名
  • 专业定制网站制作公司最近中国新闻热点大事件
  • pc网站如何做移动适配网推app怎么推广
  • wordpress建站需要多久关键词推广技巧