0Pricing
Deep Learning Academy · درس

التخزين المؤقت في المرور الأمامي وإعادة الاستخدام في العكسي

لماذا تُخزَّن التنشيطات أثناء المرور الأمامي

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

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

Two Passes, One Goal

Training each batch runs two passes: a forward pass to predict and compute loss, then a backward pass to compute gradients. They work as a pair.

The Forward Pass Computes Values

Going forward, each layer turns its input into an output and sends it onward. By the end you have a prediction and a single loss number.

Backward Needs Forward Values

To compute a layer's gradient, the chain rule needs the very activations that layer produced going forward. Those values are not optional.

So We Cache Them

During the forward pass the network quietly caches each layer's inputs and outputs in memory, ready for the backward pass to grab. 💾

A Concrete Example

The derivative of a layer often reuses its own output. For a sigmoid, the gradient depends on the saved output value, so caching it saves recomputation.

sigmoid_grad = saved_output * (1 - saved_output)

Backward Reuses the Cache

The backward pass walks layers in reverse, and at each one it pulls the matching cached values to multiply into the gradient. Nothing is recomputed.

Cache Costs Memory

Storing every activation is why training a deep net uses far more memory than just running it for predictions. Bigger nets need bigger caches.

Inference Skips the Cache

When you only need predictions, there is no backward pass, so PyTorch skips the cache entirely. That is why inference is lighter on memory.

with torch.no_grad():
    preds = model(x)

PyTorch Does This for You

Every operation on a tensor with requires_grad records what it needs into the computation graph, building the cache automatically as you go.

One Backward Frees It

By default, calling backward() consumes the cached graph and frees it. That is why a second backward() on the same graph raises an error.

loss.backward()

Why This Design Wins

Caching forward values means each gradient is one cheap lookup-and-multiply instead of a fresh recomputation, making backprop fast and exact.

Quick Check

Let's check the cache idea.

Recap

The forward pass caches activations, and the backward pass reuses them to build gradients. That trade of memory for speed is what makes backprop practical. 💾

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

هل درس «التخزين المؤقت في المرور الأمامي وإعادة الاستخدام في العكسي» مجاني؟

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

ماذا ستتعلم في «التخزين المؤقت في المرور الأمامي وإعادة الاستخدام في العكسي»؟

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

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

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

كم من الوقت يستغرق درس «التخزين المؤقت في المرور الأمامي وإعادة الاستخدام في العكسي»؟

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

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

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

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

  1. قاعدة السلسلة، طبقة بعد طبقة
  2. التخزين المؤقت في المرور الأمامي وإعادة الاستخدام في العكسي
  3. إجراء Backprop لشبكة صغيرة يدويًا
  4. التدرجات المتلاشية والمتفجرة
← العودة إلى Deep Learning Academy