python中dot函数的问题

Python018

python中dot函数的问题,第1张

在PyCharm里运行正常,Python3.6.4

import numpy as np

A = [1, 1]

B = np.array([1, 2])

C = np.sum(A*B)

D = np.dot(A, B)

print(C)

print(D)

输出:

3

3

这里a的shape是(3,3),b的shape是(3,),进行的就是普通的点积操作的。

14 = 1 * 1 + 2 * 2 + 3 * 3

32 = 4 * 1 + 5 * 2 + 6 * 3

50 = 7 * 1 + 8 * 2 + 9 * 3