美文网首页
the different between np.dot and

the different between np.dot and

作者: uurr | 来源:发表于2018-08-27 15:42 被阅读0次

np.dot is the dot product of two matrices.

|A B| . |E F|    |A*E+B*G  A*F+B*H|

      =

|C D|  |G H|   |C*E+D*G  C*F+D*H|

Whereas np.multiply does an element-wise multiplication of two matrices.

|A B| ⊙ |E F|    |A*E B*F|

      =

|C D|    |G H|        |C*G D*H|

When used with np.sum, the result being equal is merely a coincidence.

>>> np.dot([[1,2], [3,4]], [[1,2], [2,3]])array([[ 5,  8],      [11, 18]])

>>> np.multiply([[1,2], [3,4]], [[1,2], [2,3]])array([[ 1,  4],      [ 6, 12]])

>>> np.sum(np.dot([[1,2], [3,4]], [[1,2], [2,3]]))42

>>> np.sum(np.multiply([[1,2], [3,4]], [[1,2], [2,3]]))23

statckoverflow 上的解释

相关文章

网友评论

      本文标题:the different between np.dot and

      本文链接:https://www.haomeiwen.com/subject/dvqtwftx.html