# 深度学习中的基础线代知识-初学者指南

```# Multiply two arrays x = [1,2,3]
y = [2,3,4]
product = []
for i in range(len(x)):
product.append(x[i]*y[i])# Linear algebra versionx = numpy.array([1,2,3])
y = numpy.array([2,3,4])
x * y```

`y = np.array([1,2,3])x = np.array([2,3,4])y + x = [3, 5, 7]y - x = [-1, -1, -1]y / x = [.5, .67, .75]`

* 请参阅下面关于 numpy 中的 broadcasting 方法详细信息。

```y = np.array([1,2,3])
x = np.array([2,3,4])
np.dot(y,x) = 20```

```y = np.array([1,2,3])
x = np.array([2,3,4])
y * x = [2, 6, 12]```

```a = np.array([
[1,2,3],
[4,5,6]
])
a.shape == (2,3)
b = np.array([
[1,2,3]
])
b.shape == (1,3)```

```a = np.array([
[1,2],
[3,4]
])
b = np.array([
[1,2],
[3,4]
])
a + b[[2, 4],
[6, 8]]a — b[[0, 0],
[0, 0]]```

1. Â Â Â Â 两个矩阵维度相等，或

2. Â Â 一个矩阵的维度为 1

```a = np.array([
[1],
[2]
])
b = np.array([
[3,4],
[5,6]
])
c = np.array([
[1,2]
])# Same no. of rows# Different no. of columns# but a has one column so this worksa * b
[[ 3, 4],
[10, 12]]# Same no. of columns# Different no. of rows# but c has one row so this worksb * c
[[ 3, 8],
[5, 12]]# Different no. of columns# Different no. of rows# but both a and c meet the # size 1 requirement rulea + c
[[2, 3],
[3, 4]]```

```a = np.array(
[[2,3],
[2,3]])
b = np.array(
[[3,4],
[5,6]])# Uses python's multiply operatora * b
[[ 6, 12],
[10, 18]]```

1. 矩阵 旋转 90 °

2. 反转每行元素的顺序（例如 [a b c] 变为 [c b a] ）

```a = np.array([
[1, 2],
[3, 4]])
a.T[[1, 3],
[2, 4]]```

1. Â Â Â Â 第一矩阵的列数必须等于第二个矩阵 的行数

2. Â Â M × N 矩阵和 N × K 矩阵的乘积是 M × K 矩阵。 新矩阵取第一个矩阵的行和第二个矩阵的列。

705 篇文章58 人订阅

0 条评论

## 相关文章

9710

### 分类-回归树模型（CART）在R语言中的实现

CART模型 ，即Classification And Regression Trees。它和一般回归分析类似，是用来对变量进行解释和预测的工具，也是数据挖掘中...

80640

17340

408100

11720

14010

22040

11930

1.7K70

30020