np.eye() से Identity Matrix
np.eye() एक identity matrix बनाता है: diagonal के साथ ones और बाकी हर जगह zeros।
In this page:
Syntax
np.eye(n)
np.eye(rows, cols, k=offset)
np.eye()
Identity matrix number 1 का matrix equivalent है: इससे multiply करना कुछ नहीं बदलता। np.eye(n) एक n by n identity देता है; np.identity(n) similar है। k argument diagonal को ऊपर या नीचे shift करता है।
Note:
np.diag आपकी अपनी diagonal values से एक matrix बना सकता है।
उदाहरण: np.eye()
import numpy as np
print(np.eye(3))
print(np.eye(3, k=1, dtype=int))
# Output:
# [[1. 0. 0.]
# [0. 1. 0.]
# [0. 0. 1.]]
# [[0 1 0]
# [0 0 1]
# [0 0 0]]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- एक integer size की बजाय एक shape tuple pass करना
- यह भूल जाना कि result default से float है
- eye को ones से confuse करना
चैप्टर सारांश
- eye(n) एक identity matrix बनाता है
- k diagonal shift करता है
- Default dtype float है
- identity से multiply करना एक matrix unchanged छोड़ता है
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: