Numpy文档中提到的“ sum product”是什么意思?

杰罗姆·L

在《 NumPy v1.15参考指南》中,numpy.dot的文档使用“和积”的概念。

即,我们阅读以下内容:

  • 如果a是ND数组,b是一维数组,则它是a和b的最后一个轴上的总和。
  • 如果a是ND数组而b是MD数组(其中M> = 2),则它是a的最后一个轴和b的倒数第二个轴的和积:
    dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])

“和积”概念的定义是什么?
(例如,在Wikipedia上找不到这样的定义。)

hpaulj

https://zh.wikipedia.org/wiki/Matrix_multiplication

That is, the entry c[i,j] of the product is obtained by multiplying 
term-by-term the entries of the ith row of A and the jth column of B, 
and summing these m products. In other words, c[i,j] is the dot product 
of the ith row of A and the jth column of B.

https://zh.wikipedia.org/wiki/点产品

Algebraically, the dot product is the sum of the products of the 
corresponding entries of the two sequences of numbers.

在早期的数学课程中,您是不是通过一根手指在的行A上下滑动来学习矩阵乘积,B将数字对混合并求和?该动议是我对如何使用该产品的直觉的一部分。


对于1D第二个参数的情况下,np.dotnp.matmul产生同样的事情,但不同的形容行动:

  • 如果a是ND数组且b是一维数组,则它是和的最后一个轴的ab

  • 如果第二个参数是1-D,则通过在其维数后附加1来将其提升为矩阵。矩阵相乘后,将附加的1删除。

    在[103]中:np.dot([[1,2 ,, [3,4]],[1,2])Out [103]:array([5,11])在[104]中:np.matmul ([[1,2],[3,4]],[1,2])Out [104]:数组([5,11])

将尺寸附加到B,可以:

In [105]: np.matmul([[1,2],[3,4]], [[1],[2]])
Out[105]: 
array([[ 5],
       [11]])

最后一个是(2,2)和(2,1)=>(2,1)

有时用以下einsum术语表达动作会更清晰

In [107]: np.einsum('ij,j->i', [[1,2],[3,4]], [1,2])
Out[107]: array([ 5, 11])

j,两个数组的最后一个轴都是“求和”的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Golang文档中“ interface {}”之前的“ a”和“ ...”是什么意思?

__block在Apple文档示例代码中是什么意思?

Lisp文档模板中的星号是什么意思?

$ sum:1在Mongo中是什么意思

Elm文档-“ a”是什么意思?

X [:,:,::,i]在numpy中是什么意思?

帮助文档中的[],<>,-和-是什么意思?

节点文档中的此“…$ {…}…”代码是什么意思?

@在弹性搜索文档中是什么意思?

git文档中行尾的“签出代码”是什么意思?

为什么文档中提到padnone模仿内置地图的行为?

在Hugo文档中,“⊢-^-and”和类似词是什么意思?

Liferay文档的“不使用索引器”是什么意思

是什么意思 '?' 在球拍文档中?

[x] *在python函数文档中是什么意思?

调用numpy数组时,“ [[]]”是什么意思?

在NumPy Python中是什么意思?

Express.js文档嵌套[]是什么意思?

[...,None]在Numpy中是什么意思?

('foo','bar')[sum(arr)%2]是什么意思?

TLS文档中的这种表示法是什么意思?

func.sum(TableName.count)是什么意思?

vsnprintf文档中“编码错误”是什么意思?

Redis HMSET文档:“哈希”是什么意思?

在 Java 中 sum [i++] 是什么意思?

函数文档的参数中的方括号是什么意思?

提到 istio 或 kubernetes 时,“内部部署”是什么意思?

haskell 文档中“Integral a => Enum (Ratio a)”是什么意思?

文档中的方括号是什么意思?