Articles → Numpy → Create An Identity Matrix In Numpy

Create An Identity Matrix In Numpy






What Is An Identity Matrix?




Picture showing the sample identity matrix
Click to Enlarge


Syntax


Eye(dimensions)



Example


import numpy as np

print("====2 ROWS and 2 COLUMNS======")
print(np.eye(2))
print("====3 ROWS and 3 COLUMNS======")
print(np.eye(3))



Output


Picture showing the output of the identity matrix in NumPy
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, March 25, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250