0Pricing
Deep Learning Academy · درس

أول torch.tensor لك

أنشئ Tensor واطبع شكله ونوع بياناته

أول torch.tensor لك درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Meet the Tensor

A tensor is PyTorch's core data container, a grid of numbers much like a NumPy array but ready to run on a GPU. 🧮

Create One from a List

The simplest way to make a tensor is torch.tensor from a Python list. PyTorch copies your numbers into a fast numerical grid.

x = torch.tensor([1, 2, 3])

Print It Out

Printing a tensor shows its values wrapped in tensor(...), so you always know you are looking at PyTorch data, not a plain list.

print(x)

Shape Describes Structure

The shape tells you the size along each dimension. A flat list of three values has a shape of three.

print(x.shape)

Build a 2D Tensor

Nest lists to make a grid. This matrix has two rows and three columns, so its shape reads as two by three.

m = torch.tensor([[1, 2, 3], [4, 5, 6]])

Dtype Is the Number Type

Every tensor has a dtype, the kind of number it stores. Whole numbers become int64, decimals become float32 by default.

print(x.dtype)

Floats for Training

Networks learn with decimals, so most model data is float32. Add a decimal point and PyTorch picks the float type for you.

y = torch.tensor([1.0, 2.0, 3.0])

Set the Dtype Yourself

You can request a type directly with the dtype argument, which is handy when you need floats from integer input.

z = torch.tensor([1, 2], dtype=torch.float32)

Tensors Full of Zeros

Need a blank tensor of a given size? torch.zeros fills the shape you ask for with zeros, perfect as a starting buffer.

torch.zeros(2, 3)

Random Tensors

Model weights often start random. torch.rand gives a tensor of the shape you choose, filled with values between zero and one.

torch.rand(2, 3)

Count the Dimensions

The number of dimensions is the tensor's rank. Read it with .ndim: a vector is rank one, a matrix is rank two.

print(m.ndim)

Quick Check

Reason about the shape of a nested-list tensor.

Recap

You created tensors from lists, read their shape and dtype, and made zeros and random grids. This is the data deep learning runs on. ✅

الأسئلة الشائعة

هل درس «أول torch.tensor لك» مجاني؟

نعم — نص درس «أول torch.tensor لك» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

ماذا ستتعلم في «أول torch.tensor لك»؟

أنشئ Tensor واطبع شكله ونوع بياناته تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟

لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «أول torch.tensor لك»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟

نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. تثبيت PyTorch والتحقق من استيراده
  2. CPU مقابل GPU مقابل MPS: اختر جهازًا
  3. دفاتر الملاحظات والبرامج والبذور القابلة لإعادة الإنتاج
  4. أول torch.tensor لك
← العودة إلى Deep Learning Academy