Numpy 矩阵乘法

一、环境

PyCharm 2020.2.X 内的 jupyter notebook

二、代码示例

1、示例一

import numpy as np
x = np.array([[1],
              [2]])
y = np.array([[3, 4]])
np.dot(x, y)

输出结果:

array([[3, 4],
       [6, 8]])

2、示例二

A = np.array([[4, 3, 1],
              [2, 1, 3],
              [3, 1, 2]])
B = np.array([[2, 2],
              [1, 3],
              [0, 1]])
np.dot(A, B)

输出结果:

array([[11, 18],
       [ 5, 10],
       [ 7, 11]])

按:np.dot(x, y) 等价于 x.dot(y)。

原文地址:https://www.cnblogs.com/fanlumaster/p/14398188.html