np.identity(n,dtype=None)
identity输出行数和列数都是n的矩阵,其中矩阵主对角线为1,其余地方为0
dtype:表示的是输出的类型,默认是float
np.identity(3,float)
#array([[1 0 0]
[0 1 0]
[0 0 1]])
np.identity(n,dtype=None)
identity输出行数和列数都是n的矩阵,其中矩阵主对角线为1,其余地方为0
dtype:表示的是输出的类型,默认是float
np.identity(3,float)
#array([[1 0 0]
[0 1 0]
[0 0 1]])