COE 592Lecture 4.2المحاضرة 4.2Part 02الجزء 02
Why every layer needs its own pruning ratioلماذا تحتاج كل طبقة نسبة تقليم خاصة بها
Uniform shrinking loses to non-uniform pruning, so each layer needs its own ratio. Sensitivity analysis measures how much accuracy each layer loses as it is pruned harder.التصغير المنتظم يخسر أمام التقليم غير المنتظم، لذا تحتاج كل طبقة نسبتها الخاصة. تحليل الحساسية (sensitivity analysis) يقيس مقدار الدقة التي تفقدها كل طبقة كلما قُلّمت بقوة أكبر.
- Conceptsالمفاهيم
- 3
- Slidesالشرائح
- 8-17
- Readingمدة القراءة
- 18 min18 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
Every embedded deployment you will ship in this course, and every exam question on this lecture, starts from one decision: how much to prune each layer. Get it wrong by treating all layers alike and you pay accuracy at the same latency, about 2.1 points on MobileNet at roughly 70 ms. Get it right per layer and you have the foundation that AMC, NetAdapt and the threshold method in the next part all build on.
Part 01 left two questions open, and this part answers the first: what pruning ratio should each layer get? The answer comes in three moves. First the evidence that one ratio for all layers is a bad idea. Then the reason, which is that layers differ in sensitivity. Then the measurement, a sweep that prunes one layer at a time and records how much accuracy it costs, producing the family of curves that the next part reads ratios from.
كل نشر على الأنظمة المدمجة ستنفذه في هذا المقرر، وكل سؤال امتحان عن هذه المحاضرة، يبدأ من قرار واحد: كم نقلّم من كل طبقة؟ إذا أخطأت فيه وعاملت كل الطبقات بالطريقة نفسها، دفعت ثمنه دقةً عند زمن الاستجابة نفسه، أي نحو 2.1 points في MobileNet عند حوالي 70 ms. وإذا أصبت فيه لكل طبقة على حدة، صار عندك الأساس الذي تبني عليه AMC وNetAdapt وطريقة العتبة في الجزء التالي.
ترك الجزء 01 سؤالين مفتوحين، وهذا الجزء يجيب عن الأول: ما نسبة التقليم (pruning ratio) التي تستحقها كل طبقة؟ تأتي الإجابة في ثلاث خطوات. أولًا الدليل على أن نسبة واحدة لكل الطبقات فكرة سيئة. ثم السبب، وهو أن الطبقات تختلف في حساسيتها. ثم القياس، وهو مسح يقلّم طبقة واحدة في كل مرة ويسجّل كم يكلّف ذلك من الدقة، فينتج عائلة المنحنيات التي يقرأ منها الجزء التالي النسب.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain, with the MobileNet numbers, why non-uniform pruning dominates uniform shrinking on accuracy versus latency.اشرح، بأرقام MobileNet، لماذا يتفوق التقليم غير المنتظم على التصغير المنتظم في الموازنة بين الدقة وزمن الاستجابة.
- Define layer sensitivity and Delta Acc, and give three reasons the first layer is usually the most sensitive.عرّف حساسية الطبقة (layer sensitivity) و Delta Acc، واذكر ثلاثة أسباب تجعل الطبقة الأولى عادةً هي الأكثر حساسية.
- Carry out the four-step sensitivity sweep and read a sensitivity chart for VGG-11 on CIFAR-10.نفّذ خطوات مسح الحساسية الأربع، واقرأ مخطط الحساسية لـ VGG-11 على CIFAR-10.
- Compute the evaluation cost of a sweep as layers times ratios, and explain why it is evaluation only, not training.احسب تكلفة التقييم في المسح بوصفها عدد الطبقات مضروبًا في عدد النسب، واشرح لماذا هو تقييم فقط وليس تدريبًا.
- State what the sweep cannot tell you (interactions between layers), preparing for the threshold and automated methods that follow.اذكر ما لا يستطيع المسح أن يخبرك به (التفاعلات بين الطبقات)، تمهيدًا لطريقة العتبة والطرق المؤتمتة التي تأتي بعده.
Start with a measurement, not a principle. Take MobileNet on ImageNet and run it on a Google Pixel 1 CPU with TensorFlow Lite. The dense network scores 70.6% top-1 at 123.3 ms per image. Now shrink it two different ways to roughly half the work. The first way multiplies every layer's width by 0.75, the built-in MobileNet knob. The second way, AMC, lets every layer keep a different fraction of its channels (He et al., ECCV 2018, Table 4). MMACs counts millions of multiply-accumulate operations per image, a hardware-neutral measure of compute; a FLOPs target asks AMC to halve that compute, while a latency target asks it to halve measured time on the phone.
ابدأ بقياس لا بمبدأ. خذ MobileNet على ImageNet وشغّله على معالج Google Pixel 1 CPU باستخدام TensorFlow Lite. الشبكة الكثيفة (dense) تحقق 70.6% في top-1 بزمن 123.3 ms لكل صورة. الآن صغّرها بطريقتين مختلفتين إلى نحو نصف العمل تقريبًا. الطريقة الأولى تضرب عرض كل طبقة في 0.75، وهو المقبض المدمج في MobileNet. الطريقة الثانية، AMC، تسمح لكل طبقة أن تحتفظ بنسبة مختلفة من قنواتها (He et al., ECCV 2018, Table 4). يعدّ MMACs ملايين عمليات الضرب والتجميع (multiply-accumulate) لكل صورة، وهو مقياس للحوسبة لا يرتبط بعتاد معين. هدف FLOPs يطلب من AMC أن يخفض هذه الحوسبة إلى النصف، بينما هدف زمن الاستجابة (latency) يطلب منه أن يخفض الزمن المقاس على الهاتف إلى النصف.
| Modelالنموذج | Top-1Top-1 | MMACsMMACs | Pixel 1 latencyزمن الاستجابة على Pixel 1 |
|---|---|---|---|
| 1.0 MobileNet (dense)1.0 MobileNet (كثيف) | 70.6%70.6% | 569569 | 123.3 ms123.3 ms |
| 0.75 MobileNet (uniform width multiplier)0.75 MobileNet (مضاعف عرض منتظم) | 68.4%68.4% | 325325 | 72.3 ms72.3 ms |
| AMC, 50% FLOPs targetAMC، هدف 50% من FLOPs | 70.5%70.5% | 285285 | 68.3 ms68.3 ms |
| AMC, 50% latency targetAMC، هدف 50% من زمن الاستجابة | 70.2%70.2% | 272272 | 63.3 ms63.3 ms |
Read the middle two rows against each other. At nearly the same latency, 72.3 ms versus 68.3 ms, the per-layer version keeps 2.1 points more accuracy. Read the first and third rows together and the gap is even more striking: AMC's 68.3 ms model loses only 0.1 points against the full network at 123.3 ms. Slide 9 plots the same story as a chart (AMC Figure 5b), and the values read off it land in one table.
قارن الصفين الأوسطين أحدهما بالآخر. عند زمن استجابة متقارب جدًا، 72.3 ms مقابل 68.3 ms، تحتفظ النسخة ذات النسب الخاصة بكل طبقة بدقة أعلى بمقدار 2.1 points. واقرأ الصفين الأول والثالث معًا تجد الفجوة أوضح: نموذج AMC ذو 68.3 ms يخسر 0.1 points فقط مقارنة بالشبكة الكاملة عند 123.3 ms. الشريحة 9 ترسم القصة نفسها في مخطط (AMC Figure 5b)، والقيم المقروءة منه مجموعة في جدول واحد.
| Seriesالسلسلة | Latencyزمن الاستجابة | Top-1Top-1 |
|---|---|---|
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 52 ms52 ms | 67.4%67.4% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 72 ms72 ms | 68.4%68.4% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 91 ms91 ms | 69.1%69.1% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 123 ms123 ms | 70.6%70.6% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 52 ms52 ms | 69.2%69.2% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 63 ms63 ms | 70.2%70.2% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 68 ms68 ms | 70.5%70.5% |
Every AMC point sits above every uniform point. The uniform line on that chart mixes MobileNet's width multiplier with its input-resolution multiplier, which is why it has four points while Table 4 lists two; either knob shrinks every layer by the same factor.
كل نقطة لـ AMC تقع فوق كل نقطة منتظمة. الخط المنتظم في ذلك المخطط يخلط بين مضاعف العرض (width multiplier) في MobileNet ومضاعف دقة الصورة المدخلة (resolution multiplier)، ولهذا فيه أربع نقاط بينما يذكر Table 4 نقطتين فقط. وأيّ المقبضين استخدمت فإنه يصغّر كل طبقة بالمعامل نفسه.
The two stacks of bars on the slide are the whole idea in one picture. Uniform shrinking keeps every layer the same shape, just thinner: MobileNet's width multiplier alpha "thins a network uniformly at each layer" (Howard et al. 2017, section 3.3). Per-layer channel pruning ends with a ragged stack, some layers barely touched and others cut hard, because each layer got its own pruning ratio.
مكدسا الأعمدة في الشريحة يلخصان الفكرة كلها في صورة واحدة. Uniform shrinking (التصغير المنتظم) يُبقي كل طبقة على شكلها نفسه لكن أنحف: مضاعف العرض alpha في MobileNet "يُنحّف الشبكة بانتظام عند كل طبقة" (Howard et al. 2017, section 3.3). أما channel pruning (تقليم القنوات) لكل طبقة فينتهي بمكدس غير متساوٍ، بعض الطبقات بالكاد مُسّت وأخرى قُصّت بشدة، لأن كل طبقة حصلت على pruning ratio (نسبة تقليم) خاصة بها.
Why the ragged stack winsلماذا يفوز المكدس غير المتساوي
Uniform shrinking rests on a hidden assumption: that every layer has the same slack. It does not. Han et al. (NeurIPS 2015, section 5) found that "the first convolutional layer, which interacts with the input image directly, is most sensitive to pruning", and suspected this sensitivity is "due to the input layer having only 3 channels and thus less redundancy than the other convolutional layers". The AMC paper records the standard hand-crafted rule of thumb that grew from such findings, one it then argues is non-optimal because layers are not independent: "prune less parameters in the first layer which extracts low level features and have the least amount of parameters". To see how little the first layer has to give, count the weights of the first six convolution layers of VGG-11 configuration A (Simonyan and Zisserman 2015, Table 1), each a 3 x 3 kernel over its input channels.
يقوم التصغير المنتظم على افتراض خفي: أن لكل طبقة الهامش نفسه من الفائض. وهذا غير صحيح. وجد Han et al. (NeurIPS 2015, section 5) أن "طبقة الالتفاف الأولى، التي تتعامل مع صورة الدخل مباشرة، هي الأكثر حساسية للتقليم"، ورجّحوا أن هذه الحساسية "سببها أن طبقة الدخل فيها 3 قنوات فقط، وبالتالي فائض أقل من طبقات الالتفاف الأخرى". وتسجّل ورقة AMC قاعدة الإبهام اليدوية المعتادة التي نشأت من مثل هذه النتائج، ثم تجادل بأنها غير مثلى لأن الطبقات ليست مستقلة: "قلّم معاملات أقل في الطبقة الأولى التي تستخرج الميزات منخفضة المستوى وفيها أقل عدد من المعاملات". ولترى كم هو قليل ما تستطيع الطبقة الأولى أن تتخلى عنه، عُدّ أوزان أول ست طبقات التفاف في VGG-11 بالتكوين A (Simonyan and Zisserman 2015, Table 1)، وكل منها نواة 3 x 3 على قنوات دخلها.
| Layerالطبقة | Shapeالأبعاد | Weightsالأوزان | Left at r = 0.9المتبقي عند r = 0.9 |
|---|---|---|---|
| L0L0 | 3 x 3 x 3 x 643 x 3 x 3 x 64 | 1,7281,728 | 173173 |
| L1L1 | 3 x 3 x 64 x 1283 x 3 x 64 x 128 | 73,72873,728 | 7,3737,373 |
| L2L2 | 3 x 3 x 128 x 2563 x 3 x 128 x 256 | 294,912294,912 | 29,49129,491 |
| L3L3 | 3 x 3 x 256 x 2563 x 3 x 256 x 256 | 589,824589,824 | 58,98258,982 |
| L4L4 | 3 x 3 x 256 x 5123 x 3 x 256 x 512 | 1,179,6481,179,648 | 117,965117,965 |
| L5L5 | 3 x 3 x 512 x 5123 x 3 x 512 x 512 | 2,359,2962,359,296 | 235,930235,930 |
Prune 90% of L0 and 173 weights are left to describe every edge and colour detector that the rest of the network depends on. Prune 90% of L5 and 235,930 weights remain. A uniform rule takes the same 90% from a 1,728-weight layer and a 2.36-million-weight layer as if both had the same room to spare. This difference in slack is what the lecture calls sensitivity, and the next concept defines it precisely.
قلّم 90% من L0 فيبقى 173 وزنًا فقط لتصف كل كاشفات الحواف والألوان التي تعتمد عليها بقية الشبكة. وقلّم 90% من L5 فيبقى 235,930 وزنًا. القاعدة المنتظمة تأخذ 90% نفسها من طبقة فيها 1,728 وزنًا ومن طبقة فيها 2.36 مليون وزن، كأن لكلتيهما المساحة نفسها للاستغناء. هذا الفرق في الفائض هو ما تسميه المحاضرة sensitivity (الحساسية)، والمفهوم التالي يعرّفه بدقة.
Quick checkاختبار سريع
On slide 9, what does uniform shrinking do to a network?في الشريحة 9، ماذا يفعل التصغير المنتظم (uniform shrinking) بالشبكة؟
Recall
Give the MobileNet numbers that show non-uniform pruning beating uniform shrinking at about the same latency.اذكر أرقام MobileNet التي تُظهر تفوق التقليم غير المنتظم على التصغير المنتظم عند زمن استجابة متقارب.
Here is the same experiment on a network you can count by hand. Train VGG-11 on CIFAR-10 until it reaches about 93% test accuracy. Prune 90% of the weights in L0, the first convolution, and touch nothing else: accuracy falls to about 32%, a drop of about 61 points. RestoreL0, prune 90% of L1 instead: accuracy falls only to about 85%, a drop of about 8. Same ratio, roughly eight times the damage.
إليك التجربة نفسها على شبكة تستطيع أن تعدّ أوزانها بيدك. درّب VGG-11 على CIFAR-10 حتى تصل إلى دقة اختبار تقارب 93%. قلّم 90% من الأوزان في L0، أي طبقة الالتفاف الأولى، ولا تلمس شيئًا آخر: تهبط الدقة إلى نحو 32%، أي انخفاض بنحو 61 points. أعد L0 كما كانت، وقلّم 90% من L1 بدلًا منها: تهبط الدقة إلى نحو 85% فقط، أي انخفاض بنحو 8. النسبة نفسها، وضرر أكبر بنحو ثماني مرات.
That difference is what layer sensitivity measures: how much accuracy the network loses when one layer alone is pruned at a given ratio, with every other layer left dense. Write the dense accuracy as Acc_dense and the accuracy after pruning only layer L_i at ratio r as Acc_r^i. The degradation is their difference.
هذا الفرق هو ما تقيسه layer sensitivity (حساسية الطبقة): مقدار الدقة التي تخسرها الشبكة عندما تُقلَّم طبقة واحدة وحدها بنسبة معينة، وتبقى كل الطبقات الأخرى كثيفة. اكتب الدقة الكثيفة على أنها Acc_dense، والدقة بعد تقليم الطبقة L_i وحدها بالنسبة r على أنها Acc_r^i. التدهور هو الفرق بينهما.
Plot Acc_r^i against r and a sensitive layer gives a steep curve while a redundant layer gives a flat one. Slide 10 states the two ends of the spectrum: some layers are more sensitive, the first layer being the usual example, and some are more redundant. The word "usual" matters, because sensitivity is measured, not assumed, and the reasons the first layer tends to top the list are worth spelling out rather than memorizing.
ارسم Acc_r^i مقابل r، فتعطيك الطبقة الحساسة منحنى حادًا، والطبقة ذات الفائض منحنى مسطحًا. تذكر الشريحة 10 طرفي الطيف: بعض الطبقات أكثر حساسية، والطبقة الأولى هي المثال المعتاد، وبعضها أكثر فائضًا (redundant). وكلمة "المعتاد" مهمة، لأن الحساسية تُقاس ولا تُفترض، والأسباب التي تجعل الطبقة الأولى تتصدر القائمة عادةً تستحق أن تُشرح لا أن تُحفظ.
Three reasons the first layer is usually most sensitiveثلاثة أسباب تجعل الطبقة الأولى عادةً هي الأكثر حساسية
- Fewest parameters. VGG-11's L0 has 1,728 weights against 73,728 in L1 and millions further in (VGG Table 1 arithmetic). Every weight removed from L0 is a larger share of what the layer knows.أقل عدد من المعاملات. في VGG-11 تحتوي L0 على 1,728 وزنًا مقابل 73,728 في L1 وملايين في الطبقات الأعمق (حساب من VGG Table 1). كل وزن يُزال من L0 يمثل حصة أكبر مما تعرفه الطبقة.
- Only three input channels. The layer sees raw RGB, so there is little redundancy to absorb a loss. This is the explanation Han et al. (2015) give for AlexNet, where the first convolution was the most sensitive layer in their per-layer sweep (Figure 6).ثلاث قنوات دخل فقط. الطبقة ترى RGB الخام، فلا يوجد فائض يُذكر يمتص الخسارة. وهذا هو التفسير الذي يقدمه Han et al. (2015) لشبكة AlexNet، حيث كانت طبقة الالتفاف الأولى هي الأكثر حساسية في مسحهم لكل طبقة (Figure 6).
- Everything downstream depends on it. Every feature in L1 through the classifier is a function of L0's output, so an error introduced there is inherited by every later layer rather than corrected.كل ما بعدها يعتمد عليها. كل ميزة من L1 حتى المصنّف هي دالة في مخرج L0، لذا فإن أي خطأ يدخل هناك ترثه كل طبقة لاحقة بدلًا من أن يُصحَّح.
Recall
Why is the first layer usually the most sensitive to pruning?لماذا تكون الطبقة الأولى عادةً هي الأكثر حساسية للتقليم؟
Recall
Write the definition of Delta Acc_r^i in words and as a formula.اكتب تعريف Delta Acc_r^i بالكلمات وبالصيغة.
If sensitivity is a curve per layer, the procedure to obtain it is fixed by the definition: isolate one layer, vary its ratio, measure, repeat. Slides 12 to 17 build that chart one curve at a time for VGG-11 on CIFAR-10. Here is the procedure as a whole, carried out on L0, then generalized.
إذا كانت الحساسية منحنى لكل طبقة، فإن طريقة الحصول عليه يحددها التعريف نفسه: اعزل طبقة واحدة، وغيّر نسبتها، وقِس، ثم كرّر. الشرائح من 12 إلى 17 تبني ذلك المخطط منحنى بعد منحنى لـ VGG-11 على CIFAR-10. وإليك الإجراء كاملًا، مطبقًا على L0، ثم معمّمًا.
Worked exampleمثال محلول
Sensitivity analysis of VGG-11 on CIFAR-10تحليل الحساسية لـ VGG-11 على CIFAR-10
Pick a layer L_i in the modelاختر طبقة L_i في النموذج
Start with L0, the first convolution, 3 x 3 x 3 x 64 with 1,728 weights. Every other layer stays exactly as trained.ابدأ بـ L0، طبقة الالتفاف الأولى، بأبعاد 3 x 3 x 3 x 64 وفيها 1,728 وزنًا. كل طبقة أخرى تبقى تمامًا كما دُرّبت.Prune only L_i with ratio r in {0, 0.1, 0.2, ..., 0.9}قلّم L_i وحدها بالنسبة r ضمن {0, 0.1, 0.2, ..., 0.9}
For each r, apply magnitude-based fine-grained pruning to that one tensor: zero the smallest r fraction of its weights by absolute value. The slide allows "other strides", for example steps of 0.05, at proportionally more cost.لكل قيمة r، طبّق تقليمًا دقيقًا (fine-grained) magnitude-based (قائمًا على المقدار) على ذلك المُوتّر (tensor) وحده: صفّر أصغر جزء r من أوزانه بحسب القيمة المطلقة. تسمح الشريحة بـ "خطوات أخرى" (other strides)، مثل خطوات بمقدار 0.05، مقابل تكلفة أكبر بالتناسب.Observe the accuracy degradation Delta Acc_r^i for each ratioلاحظ تدهور الدقة Delta Acc_r^i لكل نسبة
Evaluate the pruned model on the CIFAR-10 test set, 10,000 images, 1,000 per class (Krizhevsky). For L0 the readings are about 2 points lost at r = 0.5, 10 at 0.7, 22 at 0.8 and 61 at 0.9.قيّم النموذج المقلَّم على مجموعة اختبار CIFAR-10، وهي 10,000 صورة، 1,000 لكل فئة (Krizhevsky). بالنسبة لـ L0 تكون القراءات نحو 2 points مفقودة عند r = 0.5، و10 عند 0.7، و22 عند 0.8، و61 عند 0.9.Restore L_i and repeat the process for all layersأعد L_i كما كانت وكرّر العملية لكل الطبقات
Copy the saved dense tensor back so the next sweep starts from the same model, then move to L1, L2 and onward. Plot every layer's curve on the same axes.انسخ المُوتّر الكثيف المحفوظ وأعده مكانه حتى يبدأ المسح التالي من النموذج نفسه، ثم انتقل إلى L1 وL2 وما بعدها. ارسم منحنى كل طبقة على المحاور نفسها.A family of curves, one per layerعائلة من المنحنيات، منحنى لكل طبقة
All curves share an x axis (pruning rate) and a y axis (accuracy). Slide 21, in the next part, reads per-layer ratios from this chart by drawing a horizontal threshold across it.تشترك كل المنحنيات في محور x (نسبة التقليم) ومحور y (الدقة). الشريحة 21، في الجزء التالي، تقرأ النسب لكل طبقة من هذا المخطط برسم threshold (عتبة) أفقية عبره.
The completed chart on slide 17 is the payoff. Every layer stays close to 93% until about 50% pruning, which tells you that any one layer can lose half its weights while the rest stay dense; whether every layer can lose half at once is a different question, taken up below. Past that point the layers separate. Values below are read off the slide to the nearest point.
المخطط المكتمل في الشريحة 17 هو الحصيلة. تبقى كل طبقة قريبة من 93% حتى تقليم يقارب 50%، وهذا يخبرك أن أي طبقة واحدة يمكنها أن تخسر نصف أوزانها بينما تبقى البقية كثيفة. أما هل تستطيع كل الطبقات أن تخسر النصف في الوقت نفسه فهذا سؤال مختلف نتناوله أدناه. بعد تلك النقطة تتباعد الطبقات. القيم أدناه مقروءة من الشريحة لأقرب نقطة.
| Layerالطبقة | r = 0.5r = 0.5 | r = 0.6r = 0.6 | r = 0.7r = 0.7 | r = 0.8r = 0.8 | r = 0.9r = 0.9 |
|---|---|---|---|---|---|
| L0 (first conv, blue)L0 (الالتفاف الأول، أزرق) | 9292 | 8888 | 8383 | 7171 | 3232 |
| L1 (green)L1 (أخضر) | 9393 | 9393 | 9393 | 9292 | 8585 |
| L2 (red, added on slide 15)L2 (أحمر، أُضيف في الشريحة 15) | 9393 | 9393 | 9292 | 9090 | 7979 |
| L3 (orange)L3 (برتقالي) | 9393 | 9393 | 9191 | 8686 | 5151 |
| L4 (red, added on slide 17)L4 (أحمر، أُضيف في الشريحة 17) | 9393 | 9393 | 9090 | 7777 | 3939 |
Try the sweep yourself. The simulator holds the chart values, lets you pick the layer being pruned and slide its ratio, and reports the accuracy, the drop and how many of that layer's weights are gone. Leave the ratio at 0.9 and switch between L0 and L1 to feel the difference in one click.
جرّب المسح بنفسك. يحتوي المحاكي على قيم المخطط، ويتيح لك اختيار الطبقة التي تُقلَّم وتحريك نسبتها، ويعرض الدقة، والانخفاض، وكم من أوزان تلك الطبقة قد أُزيل. اترك النسبة عند 0.9 وبدّل بين L0 وL1 لتشعر بالفرق بنقرة واحدة.
Leave the slider at r = 0.9 and switch between L0 and L1: the first layer loses about 61 points, the second about 8. Every point on every curve comes from one evaluation with only that layer pruned and nothing retrained. Values are read from the slide chart to the nearest point, so treat them as approximate.اترك المنزلق عند r = 0.9 وبدّل بين L0 وL1: تخسر الطبقة الأولى نحو 61 نقطة، والثانية نحو 8. كل نقطة على كل منحنى تأتي من تقييم واحد قُلّمت فيه تلك الطبقة وحدها دون أي إعادة تدريب. القيم مقروءة من مخطط الشريحة إلى أقرب نقطة، فتعامل معها على أنها تقريبية.
Why each layer is swept aloneلماذا تُمسح كل طبقة وحدها
Sweeping one layer while the rest stay dense is what makes the curve interpretable. If two layers were pruned together and accuracy fell, the drop could not be attributed to either one. Isolation buys attribution. It also has a price, which the next part turns into a whole discussion: it assumes the damage from pruning several layers adds up. AMC's authors put it bluntly, the single-layer approach "assumes that errors of different pruned layers can be summed up linearly, which does not stand according to our experiments" (He et al. 2018, section 4). Keep that interaction in mind: the sweep tells you which layers are fragile, not what happens when you prune them all at once.
مسح طبقة واحدة بينما تبقى البقية كثيفة هو ما يجعل المنحنى قابلًا للتفسير. لو قُلّمت طبقتان معًا وهبطت الدقة، لما أمكن نسبة الانخفاض إلى أيٍّ منهما. العزل يشتري لك القدرة على نسبة السبب. لكن له ثمن أيضًا، يحوّله الجزء التالي إلى نقاش كامل: فهو يفترض أن الضرر الناتج عن تقليم عدة طبقات يُجمع جمعًا. ويقولها مؤلفو AMC صراحة، فالنهج أحادي الطبقة "يفترض أن أخطاء الطبقات المقلّمة المختلفة يمكن جمعها خطيًا، وهذا لا يصح بحسب تجاربنا" (He et al. 2018, section 4). أبقِ هذا interaction (التفاعل) في ذهنك: المسح يخبرك أي الطبقات هشة، لا ما يحدث حين تقلّمها كلها دفعة واحدة.
What the sweep costsكم يكلّف المسح
No gradient step runs during a sweep, but every point on every curve is one full pass over the evaluation set. The number of evaluations is the number of layers times the number of ratios, and each evaluation is a forward pass over every test image.
لا تُنفَّذ أي خطوة تدرّج (gradient step) أثناء المسح، لكن كل نقطة على كل منحنى هي مرور كامل على مجموعة التقييم. عدد التقييمات هو عدد الطبقات مضروبًا في عدد النسب، وكل تقييم هو مرور أمامي (forward pass) على كل صورة اختبار.
| Networkالشبكة | Layersالطبقات | Ratiosالنسب | Evaluationsالتقييمات | Images per evaluationالصور في كل تقييم | Forward passesالمرورات الأمامية |
|---|---|---|---|---|---|
| VGG-11 on CIFAR-10VGG-11 على CIFAR-10 | 99 | 1010 | 9090 | 10,00010,000 | 900,000900,000 |
| 50-layer network on ImageNetشبكة من 50 طبقة على ImageNet | 5050 | 1010 | 500500 | 50,00050,000 | 25 million25 مليون |
The CIFAR-10 VGG-11 behind this chart has 9 weight layers (8 convolutions plus a 1-layer classifier), so ten ratios mean 90 evaluations over the 10,000-image CIFAR-10 test set, about 900,000 forward passes. One small saving: r = 0 is the same dense model for every layer, so it only needs to be evaluated once. A 50-layer ImageNet network evaluated on the 50,000 ILSVRC validation images (Russakovsky et al. 2015) needs 25 million. The cost is linear in depth, which is tolerable for VGG-11 and painful for deep networks, and it is one of the reasons the automated methods later in this lecture, AMC and NetAdapt, search the ratios instead of sweeping them.
شبكة VGG-11 الخاصة بـ CIFAR-10 وراء هذا المخطط فيها 9 طبقات أوزان (8 طبقات التفاف ومصنّف من 1 طبقة)، لذا فإن عشر نسب تعني 90 تقييمًا على مجموعة اختبار CIFAR-10 ذات 10,000 صورة، أي نحو 900,000 مرور أمامي. وهناك توفير صغير: r = 0 هو النموذج الكثيف نفسه لكل طبقة، فيكفي تقييمه مرة واحدة. أما شبكة ImageNet من 50 طبقة تُقيَّم على صور التحقق ILSVRC البالغة 50,000 (Russakovsky et al. 2015) فتحتاج 25 million. التكلفة خطية في العمق، وهذا مقبول لـ VGG-11 ومؤلم للشبكات العميقة، وهو أحد أسباب أن الطرق المؤتمتة لاحقًا في هذه المحاضرة، AMC وNetAdapt، تبحث عن النسب بدلًا من مسحها.
The sweep in four linesالمسح في أربعة أسطر
- Inputالمدخل
- A trained dense model and a held-out evaluation setنموذج كثيف مدرَّب ومجموعة تقييم محجوزة جانبًا
- Loopالحلقة
- for each layer L_i, for each r: prune only L_i, evaluate, restoreلكل طبقة L_i، ولكل r: قلّم L_i وحدها، ثم قيّم، ثم أعدها كما كانت
- Outputالمخرج
- one curve per layer, Delta Acc_r^i against rمنحنى واحد لكل طبقة، Delta Acc_r^i مقابل r
- Costالتكلفة
- layers x ratios evaluations, no trainingعدد الطبقات x عدد النسب من التقييمات، بلا تدريب
Quick checkاختبار سريع
In the sensitivity sweep, which layers are pruned while layer L_i is being measured?في مسح الحساسية، ما الطبقات التي تُقلَّم أثناء قياس الطبقة L_i؟
Quick checkاختبار سريع
What happens to weights during a sensitivity sweep?ماذا يحدث للأوزان أثناء مسح الحساسية؟
Quick checkاختبار سريع
VGG-11 on CIFAR-10: pruning L0 to 90 percent gives about what accuracy?VGG-11 على CIFAR-10: تقليم L0 بنسبة 90% يعطي دقة تقارب كم؟
Recall
State the four steps of sensitivity analysis.اذكر الخطوات الأربع لتحليل الحساسية.
Recall
During the sweep, what state are the other layers in, and why?أثناء المسح، في أي حالة تكون الطبقات الأخرى، ولماذا؟
Recall
How many evaluations does a sweep cost, and what is it for VGG-11 with ten ratios? Does any training happen?كم تقييمًا يكلّف المسح، وكم يبلغ لـ VGG-11 بعشر نسب؟ هل يحدث أي تدريب؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Uniform shrinking gives every layer the same factor. AMC's per-layer ratios reach 70.5% at 68.3 ms, while 0.75 MobileNet reaches 68.4% at 72.3 ms.التصغير المنتظم يعطي كل طبقة المعامل نفسه. نسب AMC الخاصة بكل طبقة تصل إلى 70.5% عند 68.3 ms، بينما يصل 0.75 MobileNet إلى 68.4% عند 72.3 ms.
- Layers differ in sensitivity. The first layer of VGG-11 has only 1,728 weights and 3 input channels, and every later feature depends on its output.الطبقات تختلف في حساسيتها. الطبقة الأولى في VGG-11 فيها 1,728 وزنًا فقط و 3 قنوات دخل، وكل ميزة لاحقة تعتمد على مخرجها.
- Sensitivity analysis: pick L_i, prune only L_i at r in {0, 0.1, ..., 0.9}, record Delta Acc for each r, restore the layer, repeat for all layers.تحليل الحساسية: اختر L_i، وقلّم L_i وحدها عند r ضمن {0, 0.1, ..., 0.9}، وسجّل Delta Acc لكل r، ثم أعد الطبقة كما كانت، وكرّر ذلك لكل الطبقات.
- On VGG-11 CIFAR-10 every layer stays near 93% up to about 50% pruning. At 90%, L0 falls to about 32, L4 to 39 and L3 to 51, while L1, L2 and L5 stay near or above 80.في VGG-11 على CIFAR-10 تبقى كل طبقة قرب 93% حتى تقليم يقارب 50%. عند 90% تهبط L0 إلى نحو 32، و L4 إلى 39، و L3 إلى 51، بينما تبقى L1 و L2 و L5 قرب 80 أو فوقها.
- The sweep is evaluation only, with no fine-tuning, and costs layers times ratios evaluations: 90 for the CIFAR-10 VGG-11 with ten ratios.المسح تقييم فقط بلا ضبط دقيق (fine-tuning)، وتكلفته عدد الطبقات مضروبًا في عدد النسب من التقييمات: 90 تقييمًا لـ VGG-11 على CIFAR-10 بعشر نسب.
- Sweeping one layer at a time isolates causes but ignores interactions between layers, which is the limitation the next parts address.مسح طبقة واحدة في كل مرة يعزل الأسباب لكنه يتجاهل التفاعلات بين الطبقات، وهذا هو القصور الذي تعالجه الأجزاء التالية.
Sourcesالمصادر
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperECCV 2018, He, Lin, Liu, Wang, Li and HanTable 4 MobileNet numbers on Pixel 1, Figure 5b accuracy versus latency, section 1 first-layer heuristic, section 4 critique of single-layer sensitivity.أرقام MobileNet في الجدول 4 على Pixel 1، والشكل 5b للدقة مقابل زمن الاستجابة، والقاعدة التجريبية عن الطبقة الأولى في القسم 1، ونقد الحساسية أحادية الطبقة في القسم 4.(opens in a new tab)(يفتح في تبويب جديد)
- Learning both Weights and Connections for Efficient Neural NetworksPaperNeurIPS 2015, Han, Pool, Tran and DallyFigure 6 per-layer sensitivity of AlexNet; first conv layer most sensitive, attributed to its 3 input channels.الشكل 6 لحساسية كل طبقة في AlexNet، وطبقة الالتفاف الأولى هي الأكثر حساسية، ويُعزى ذلك إلى قنوات دخلها الثلاث.(opens in a new tab)(يفتح في تبويب جديد)
- Pruning Filters for Efficient ConvNetsPaperICLR 2017, Li, Kadav, Durdanovic, Samet and GrafSection 3.2 prune each layer independently and evaluate; section 4.1 first layer robust under filter pruning on CIFAR-10.القسم 3.2 تقليم كل طبقة باستقلال ثم التقييم، والقسم 4.1 الطبقة الأولى متينة تحت تقليم المرشحات (filter pruning) على CIFAR-10.(opens in a new tab)(يفتح في تبويب جديد)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017Section 3.3 width multiplier thins a network uniformly at each layer; Table 6: 0.75 MobileNet 68.4 percent, 325 MMACs.القسم 3.3 مضاعف العرض يُنحّف الشبكة بانتظام عند كل طبقة، والجدول 6: 0.75 MobileNet بدقة 68.4% و 325 MMACs.(opens in a new tab)(يفتح في تبويب جديد)
- Very Deep Convolutional Networks for Large-Scale Image RecognitionPaperICLR 2015, Simonyan and ZissermanTable 1 configuration A: 11 weight layers and the channel widths used for the weight counts.الجدول 1 التكوين A: 11 طبقة أوزان وعروض القنوات المستخدمة في عدّ الأوزان.(opens in a new tab)(يفتح في تبويب جديد)
- The CIFAR-10 datasetDocsAlex Krizhevsky, University of Toronto60,000 32x32 images in 10 classes; 10,000 test images with 1,000 per class.60,000 صورة بحجم 32x32 في 10 فئات، منها 10,000 صورة اختبار بواقع 1,000 لكل فئة.(opens in a new tab)(يفتح في تبويب جديد)
- ImageNet Large Scale Visual Recognition ChallengePaperIJCV 2015, Russakovsky et al.50 thousand validation images across 1,000 classes, used for the sweep-cost example.50 ألف صورة تحقق موزعة على 1,000 فئة، استُخدمت في مثال تكلفة المسح.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2023DocsMIT HAN LabLecture 4, Pruning and Sparsity Part II: the sensitivity analysis slides and VGG-11 on CIFAR-10 chart this part is built on. The linked Lab 1 notebook implements the sweep as prune one tensor, evaluate, copy the saved clone back, with no training step.المحاضرة 4، Pruning and Sparsity Part II: شرائح تحليل الحساسية ومخطط VGG-11 على CIFAR-10 اللذان يقوم عليهما هذا الجزء. ودفتر Lab 1 المرتبط ينفّذ المسح بتقليم مُوتّر واحد، ثم التقييم، ثم إعادة النسخة المحفوظة مكانه، بلا أي خطوة تدريب.(opens in a new tab)(يفتح في تبويب جديد)