- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
来自 numpy 的文档:https://numpy.org/doc/stable/reference/generated/numpy.dot.html#numpy.dot
numpy.dot(a, b, out=None)
Dot product of two arrays. Specifically,
If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).
If both a and b are 2-D arrays, it is matrix multiplication, but using matmul or a @ b is preferred.
If either a or b is 0-D (scalar), it is equivalent to multiply and using numpy.multiply(a, b) or a * b is preferred.
If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.
If a is an N-D array and b is an M-D array (where M>=2), it is a sum product over the last axis of a and the second-to-last axis of b:
>>> a
array([[1, 2],
[3, 4],
[5, 6]])
>>> b
[1, 2]
>>> a.dot(b)
array([ 5, 11, 17])
我预计这会引发错误,因为 a 的列的维度大于 b 的行的维度。
最佳答案
If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.
a
的最后一个轴有尺寸 2:
>>> a.shape
(3, 2)
匹配
b
s 大小。
关于python - 矩阵和数组的 NumPy 点积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66619157/
我是一名优秀的程序员,十分优秀!