Numpy: eye



examples/numpy/create_eye.py
import numpy as np

a = np.eye(4)
print(a)
print()

b = np.eye(3, 5)
print(b)

[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]

[[1. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0.]
 [0. 0. 1. 0. 0.]]