TVP

# 代码详解：如何在深度学习下理解线性代数？

np.random 是指一个软件包，包含用于生成随机数的方法。

## numpy code for transpos

import numpy as np

A = np.array([[1,2],

[3,4],

[5,6]]

B = np.transpose(A)

##or

B = A.T

## numpy code to create identity matrix

import numpy as np

a = np.eye(4)

A .v = λ .v

## numpy program to find eigen vectors.

from numpy import array

from numpy.linalg import eig

# define matrix

A = array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(A)

# calculate eigendecomposition

values, vectors = eig(A)

print(values)

print(vectors)

L¹范数是向量中所有元素的总和。当系统要求更高精度时，它被运用于机器学习，用于清晰地区分零元素和非零元素。L¹范数也称为曼哈顿范数。

Numpy已经在算法中大量实现了向量化。

## to add two arrays together.

## consider two basic python lists.

a = [1,2,3,4,5]

b = [2,3,4,5,6]

c = []

## without vectorization.

for i in range(len(a)):

c.append(a[i]+b[i])

## using vectorization.

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

b = np.array([2,3,4,5,6])

c = a+b

## to add two arrays together.

## consider two basic python lists.

a = np.array([1.0, 2.0, 3.0])

b = 2.0

a * b

array([ 2., 4., 6.])

this is similar to

a = np.array([1.0, 2.0, 3.0])

b = np.array([2.0, 2.0, 2.0])

a * b

array([ 2., 4., 6.])

• 发表于:
• 原文链接https://kuaibao.qq.com/s/20181220B0LIGA00?refer=cp_1026
• 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号（企鹅号）传播渠道之一，根据《腾讯内容开放平台服务协议》转载发布内容。
• 如有侵权，请联系 cloudcommunity@tencent.com 删除。

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2023-10-02

2019-10-15

Get大咖技术交流圈