← Back to NumPy Course | Chapter 12: Advanced Topics | Lesson 3 of 7

Strides क्या हैं

Strides NumPy को बताते हैं हर axis के साथ अगले element तक move करने के लिए कितने bytes jump करने हैं।

In this page:

  1. Strides
Syntax
python
arr.strides

Strides

Strides वह तरीका है जिससे NumPy एक multi-dimensional index को flat memory पर map करता है। एक C-ordered (3, 4) int64 array की strides (32, 8) हैं। Transposing data move किए बिना बस strides swap करता है, यही वजह है यह instant है।

Note: np.lib.stride_tricks.as_strided sliding windows बना सकता है लेकिन गलत इस्तेमाल होने पर invalid memory पढ़ सकता है।

उदाहरण: Strides

python
import numpy as np

a = np.arange(12, dtype=np.int64).reshape(3, 4)
print(a.strides)
print(a.T.strides)
print(a.T.flags["C_CONTIGUOUS"])

# Output:
# (32, 8)
# (8, 32)
# False
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. #}
आम गलतियां
  1. bytes में strides को element counts से confuse करना
  2. बिना care के as_strided इस्तेमाल करना
  3. यह मान लेना कि एक transpose data copy करता है
चैप्टर सारांश
  • strides प्रति axis byte steps हैं
  • Transpose strides swap करता है
  • कोई data move नहीं होता
  • as_strided powerful लेकिन risky है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.