Prerequisite:
先决条件:
In linear algebra, the identity matrix, of size n is the n × n square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by I. Also known as the unit matrix because its determinant value is 1 irrespective of size. This is the key feature of an identity matrix and it plays an important role in Linear Algebra.
在线性代数中,大小为n的恒等矩阵为n×n方阵,主对角线上为1,其他地方为零。 用I表示。 也称为单位矩阵,因为其行列式值为1 ,与大小无关。 这是单位矩阵的关键特征,并且在线性代数中起重要作用。
Syntax:
句法:
identity_matrix = eye(n)
Input parameter(s):
输入参数:
n – size of the identity matrix.
n –单位矩阵的大小。
Return value:
返回值:
A square matrix with 1 at its diagonal and rest is zero.
对角线为1且其余为零的方阵。
Applications:
应用范围:
Machine Learning
机器学习
Neural Network
神经网络
Linear Algebra - Gauss Jordan Elimination
线性代数-高斯约旦消除
使用numpy.eye()函数打印身份矩阵的Python代码 (Python code to print the identity matrix using numpy.eye() function)
# Linear Algebra Learning Sequence
# Identity matrix using numpy.eye() function
import numpy as np
# Using power function
print("\n---I(4x4)---\n", np.eye(4))
print("\n---I(6x6)---\n", np.eye(6))
Output:
输出:
---I(4x4)---
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
---I(6x6)---
[[1. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0.]
[0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 1. 0.]
[0. 0. 0. 0. 0. 1.]]
翻译自: https://www.includehelp.com/python/print-the-identity-matrix-using-numpy-eye-function.aspx