Analyze Data/Python Libraries

numpy-identity

Naranjito 2023. 6. 2. 11:03
  • identity

The identity array is a square array with ones on the main diagonal.

np.identity(1)
>>>
array([[1.]])

np.identity(2)
>>>
array([[1., 0.],
       [0., 1.]])
       
np.identity(3)
>>>
array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])
       
np.identity(4)
>>>
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

'Analyze Data > Python Libraries' 카테고리의 다른 글

EasyDict  (0) 2023.10.18
numpy-concatenate  (0) 2023.06.07
numpy-linspace, interp  (0) 2023.05.30
numpy-np.c_[] VS np.r_[]  (0) 2023.05.25
numpy-axis, expand_dims  (0) 2023.05.24