目录
一、np.dot() : 向量的内积
-
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:
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
举例


二、np.matmul():矩阵乘法
- (n,k),(k,m)->(n,m)
- the last dimension of x1 is the same size as the second-to-last dimension of x2
举例


本文详细介绍了numpy库中用于向量和矩阵运算的两个关键函数:np.dot()和np.matmul()。np.dot()主要用于计算向量的内积和多维数组的矩阵乘法,其运算规则灵活,适用于不同形状的数组。而np.matmul()则遵循更严格的矩阵乘法规则,确保输入的最后维度匹配。通过实例解析,帮助读者深入理解这两个函数的使用方法和区别。
3556

被折叠的 条评论
为什么被折叠?



