COE 592Lecture 4.2المحاضرة 4.2Part 01الجزء 01
Where we are: the pruning problem so farأين وصلنا: مسألة التقليم حتى الآن
A compact recap of lecture 04-1: pruning as constrained optimization, the granularity spectrum, magnitude as the default criterion and neuron or channel pruning as coarse-grained weight pruning, setting up the two open questions this lecture answers.مراجعة موجزة للمحاضرة 04-1: التقليم بوصفه تحسينًا مقيدًا، وطيف الدقة (granularity)، والمقدار بوصفه المعيار الافتراضي، وتقليم العصبونات أو القنوات بوصفه تقليمًا خشنًا للأوزان، تمهيدًا للسؤالين المفتوحين اللذين تجيب عنهما هذه المحاضرة.
- Conceptsالمفاهيم
- 3
- Slidesالشرائح
- 1-7
- Readingمدة القراءة
- 18 min18 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
Every method in this lecture, from sensitivity curves and AMC to NetAdapt, iterative fine-tuning, EIE and 2:4 tensor cores, is either a way of choosing how many nonzeros each layer may keep or a way of exploiting the zeros that choice creates. None of it makes sense unless the pruning problem itself is crisp in your head.
This part is a bridge, not a second lecture. The first seven slides of the deck repeat lecture 04-1 almost word for word, so the aim here is to compress what that lecture settled into one page you can reproduce under exam conditions: the formulation with every symbol defined, the reason the constraint cannot be optimized directly, the magnitude criterion on a 2 x 2 matrix, and the granularity ladder from single weights to whole channels. Expect to be asked for the formulation and for what ||W_P||_0 means, and the edge deployment in your research project starts by deciding a nonzero budget per layer, which is exactly the symbol N below.
كل طريقة في هذه المحاضرة، من منحنيات الحساسية (sensitivity curves) وAMC إلى NetAdapt وإعادة الضبط التكرارية (iterative fine-tuning) وEIE وtensor cores بنمط 2:4، إما أنها طريقة لاختيار عدد القيم غير الصفرية التي يحق لكل طبقة أن تحتفظ بها، أو طريقة للاستفادة من الأصفار التي ينتجها هذا الاختيار. لن يكون لأي من ذلك معنى ما لم تكن مسألة الـ pruning نفسها واضحة تمامًا في ذهنك.
هذا الجزء جسر، وليس محاضرة ثانية. الشرائح السبع الأولى من العرض تكرر المحاضرة 04-1 تقريبًا حرفيًا، لذلك الهدف هنا أن نضغط ما حسمته تلك المحاضرة في صفحة واحدة تستطيع إعادة كتابتها في ظروف الامتحان: الصياغة مع تعريف كل رمز فيها، وسبب عدم إمكان تحسين القيد مباشرة، ومعيار المقدار (magnitude) على مصفوفة 2 x 2، وسلّم درجات التفصيل (granularity) من الأوزان المنفردة إلى القنوات الكاملة. توقّع أن تُسأل عن الصياغة وعن معنى ||W_P||_0، كما أن النشر على الأجهزة الطرفية (edge deployment) في مشروعك البحثي يبدأ بتحديد ميزانية للقيم غير الصفرية لكل طبقة، وهي بالضبط الرمز N أدناه.
By the end you canفي نهاية هذا الجزء ستستطيع
- Write the pruning formulation and define L, x, W, W_P, ||W_P||_0 and N.أن تكتب صياغة الـ pruning وتعرّف L و x و W و W_P و ||W_P||_0 و N.
- Explain why the L0 count is neither a norm nor differentiable, and why that forces heuristic criteria.أن تشرح لماذا لا يُعدّ عدد الـ L0 معيارًا (norm) ولا دالة قابلة للاشتقاق، ولماذا يجبرنا ذلك على معايير تقريبية (heuristic).
- Reproduce the 2x2 magnitude example and state the pruned matrix and its sparsity.أن تعيد حل مثال المقدار (magnitude) على مصفوفة 2x2 وتذكر المصفوفة بعد التقليم ونسبة الـ sparsity فيها.
- Place fine-grained through channel pruning on the flexibility versus hardware-friendliness axis.أن تضع مستويات التقليم من الدقيق (fine-grained) حتى تقليم القنوات (channel) على محور المرونة مقابل ملاءمة العتاد.
- Say which of the five questions 04-1 answered and which two this lecture answers.أن تذكر أي الأسئلة الخمسة أجابت عنها المحاضرة 04-1، وأي سؤالين تجيب عنهما هذه المحاضرة.
Take one layer with 16 weights and suppose the deployment budget allows you to keep only 8 of them. Which eight? That single question is the whole of Pruning. Every answer in lectures 04-1 and 04-2 is a different way of choosing those eight, and every hardware trick at the end of this lecture is a way of profiting from the eight zeros that remain.
خذ طبقة واحدة فيها 16 وزنًا، وافترض أن ميزانية النشر تسمح لك بالاحتفاظ بـ 8 منها فقط. أي ثمانية؟ هذا السؤال الواحد هو كل ما في الـ pruning. كل إجابة في المحاضرتين 04-1 و04-2 هي طريقة مختلفة لاختيار تلك الثمانية، وكل حيلة عتادية في نهاية هذه المحاضرة هي طريقة للاستفادة من الأصفار الثمانية المتبقية.
The general rule states the question as a constrained optimization. Among all weight tensors that have at most N nonzero entries, pick the one that makes the training loss smallest.
القاعدة العامة تصوغ السؤال على أنه مسألة تحسين مقيّدة (constrained optimization): من بين كل موترات الأوزان (weight tensors) التي فيها N قيمة غير صفرية على الأكثر، اختر الموتر الذي يجعل خسارة التدريب (training loss) أصغر ما يمكن.
Every symbol in the formulationكل رمز في الصياغة
- L
- The training objective, the same loss the network was trained with, for example cross-entropyهدف التدريب، وهو دالة الخسارة نفسها التي دُرّبت بها الشبكة، مثل cross-entropy
- x
- The input data the loss is evaluated onبيانات الإدخال التي تُحسب عليها الخسارة
- W
- The original dense weights of the trained networkالأوزان الأصلية الكثيفة (dense) للشبكة المدرّبة
- W_P
- The pruned weights: the same shape as W, with some entries forced to exactly zeroالأوزان بعد التقليم: لها شكل W نفسه، مع إجبار بعض عناصرها على أن تساوي صفرًا بالضبط
- ||W_P||_0
- The number of nonzero entries in W_P, the L0 normعدد العناصر غير الصفرية في W_P، وهو ما يُسمّى L0 norm
- N
- The target number of nonzeros, the budget the pruned network must respectالعدد المستهدف من القيم غير الصفرية، أي الميزانية التي يجب أن تلتزم بها الشبكة بعد التقليم
Read the formula from the inside out. L(x; W_P) asks how badly the network with weights W_P does on the data. The arg min says we want the W_P that makes that number smallest. The constraint says we may only search among tensors whose nonzero count fits the budget. The budget is what connects this formula to the Pruning ratio of the next part: with M weights in the layer and N survivors, the fraction removed is 1 - N / M, so for M = 16 and N = 8 the layer is 50% sparse. The weight count is written M rather than |W|, because |W| below means the element-wise absolute value.
اقرأ الصيغة من الداخل إلى الخارج. L(x; W_P) تسأل: ما مدى سوء أداء الشبكة ذات الأوزان W_P على البيانات؟ والـ arg min تقول إننا نريد W_P التي تجعل هذا الرقم أصغر ما يمكن. والقيد يقول إنه لا يُسمح لنا بالبحث إلا بين الموترات التي يتسع عدد قيمها غير الصفرية ضمن الميزانية. والميزانية هي ما يربط هذه الصيغة بالـ pruning ratio (نسبة التقليم) في الجزء التالي: إذا كان في الطبقة M وزنًا وبقي منها N، فالنسبة المحذوفة هي 1 - N / M، فعند M = 16 وN = 8 تكون الطبقة متناثرة (sparse) بنسبة 50%. نكتب عدد الأوزان M بدلًا من |W| لأن |W| فيما يلي تعني القيمة المطلقة عنصرًا بعنصر.
Why nobody solves this formula directlyلماذا لا يحل أحد هذه الصيغة مباشرة
The formula looks like something you could hand to gradient descent, and that is the trap. The nonzero count is a step function: nudge a weight from 0.30 to 0.31 and the count does not move, set it to exactly zero and the count drops by one. Its gradient is zero almost everywhere and undefined at zero, so no gradient flows through the constraint. Louizos, Welling and Kingma open their ICLR 2018 paper on this exact point: the L0 norm of the weights is non-differentiable, which is why it cannot simply be added to the training objective. Without a gradient, the exact problem is a combinatorial search, choosing which N of the M positions to keep, and for a layer with millions of weights that search is hopeless.
تبدو الصيغة كأنها شيء تستطيع تسليمه إلى خوارزمية الانحدار التدرجي (gradient descent)، وهذا هو الفخ. عدد القيم غير الصفرية دالة درجية (step function): حرّك وزنًا من 0.30 إلى 0.31 ولن يتغير العدد، واجعله صفرًا بالضبط فينقص العدد بواحد. تدرّجها صفر في كل مكان تقريبًا وغير معرّف عند الصفر، لذلك لا يمر أي تدرّج عبر القيد. يفتتح Louizos وWelling وKingma ورقتهم في ICLR 2018 بهذه النقطة بالذات: الـ L0 norm للأوزان غير قابل للاشتقاق، ولهذا لا يمكن ببساطة إضافته إلى هدف التدريب. ومن دون تدرّج تصبح المسألة الدقيقة بحثًا تركيبيًا (combinatorial search)، أي اختيار أي N من المواقع الـ M نحتفظ بها، وفي طبقة فيها ملايين الأوزان يكون هذا البحث ميؤوسًا منه.
The heuristics are not arbitrary. Every one of them is a proxy for the same quantity: how much would L change if this weight were removed. The constraint side of the formula only fixes the budget; the loss side is what actually decides the answer, so the best criterion is the one whose ranking best tracks the change in loss. That is why the slide on selection later in this part says that the less useful the removed neurons are, the better the pruned network performs. Useful means low loss change, nothing else.
هذه المعايير التقريبية ليست عشوائية. كل واحد منها تقريب للكمية نفسها: كم ستتغير L لو حُذف هذا الوزن. جانب القيد في الصيغة يحدد الميزانية فقط، أما جانب الخسارة فهو الذي يحسم الإجابة فعلًا، لذلك أفضل معيار هو الذي يتتبع ترتيبه التغيّر في الخسارة بأدق صورة. ولهذا تقول شريحة الاختيار لاحقًا في هذا الجزء إنه كلما كانت العصبونات المحذوفة أقل فائدة، كان أداء الشبكة بعد التقليم أفضل. وقليل الفائدة يعني تغيّرًا صغيرًا في الخسارة، لا أكثر.
| Modelالنموذج | Beforeقبل | Afterبعد | Reductionنسبة التخفيض |
|---|---|---|---|
| AlexNetAlexNet | 61M61M | 6.7M6.7M | 9x9x |
| VGG-16VGG-16 | 138M138M | 10.3M10.3M | 13x13x |
Recall
Write the pruning formulation and name every symbol.اكتب صياغة الـ pruning وسمِّ كل رمز فيها.
Recall
Why can you not just run gradient descent on the constraint ||W_P||_0 <= N?لماذا لا تستطيع ببساطة تطبيق gradient descent على القيد ||W_P||_0 <= N؟
Quick checkاختبار سريع
In the pruning formulation, what does the term ||W_P||_0 measure?في صياغة الـ pruning، ماذا يقيس الحد ||W_P||_0؟
Quick checkاختبار سريع
Why do all pruning criteria rank weights by an importance score instead of solving the arg min directly?لماذا ترتّب كل معايير الـ pruning الأوزان بدرجة أهمية بدلًا من حل الـ arg min مباشرة؟
The formulation says nothing about how to find good survivors. Lecture 04-1 gave two practical answers, a shape and a score, and slides 4 to 6 of this deck replay them in the space of one minute. Start with the score on the smallest example that still teaches something: a 2 x 2 weight matrix that must lose half of its entries.
الصياغة لا تقول شيئًا عن كيفية إيجاد الأوزان الجيدة التي تبقى. أعطت المحاضرة 04-1 إجابتين عمليتين: شكلًا ودرجة، والشرائح من 4 إلى 6 في هذا العرض تعيدهما في دقيقة واحدة. ابدأ بالدرجة على أصغر مثال لا يزال يعلّم شيئًا: مصفوفة أوزان 2 x 2 يجب أن تفقد نصف عناصرها.
Worked exampleمثال محلول
Magnitude pruning on a 2 x 2 matrix at 50%الـ Magnitude pruning على مصفوفة 2 x 2 بنسبة 50%
Start from the weightsابدأ من الأوزان
W = [[3, -2], [1, -5]], four weights, two of which must go.W = [[3, -2], [1, -5]]، أربعة أوزان يجب أن يُحذف اثنان منها.Score every weight by its absolute valueأعطِ كل وزن درجة تساوي قيمته المطلقة
Element-wise |W| = [[3, 2], [1, 5]]. The sign is discarded; only distance from zero counts.القيمة المطلقة عنصرًا بعنصر |W| = [[3, 2], [1, 5]]. الإشارة تُهمل، والمهم فقط البعد عن الصفر.Keep the N = 2 highest scoresاحتفظ بأعلى N = 2 من الدرجات
Sorted importances are 5, 3, 2, 1. The top two are 5 and 3, which belong to -5 and 3. The entries scored 2 and 1 are set to zero.الأهميات بعد الترتيب هي 5, 3, 2, 1. الأعلى اثنتان هما 5 و3، وهما تعودان إلى -5 و3. العنصران اللذان درجتهما 2 و1 يُجعلان صفرًا.Resultالنتيجة
W_P = [[3, 0], [0, -5]], with ||W_P||_0 = 2 and sparsity 50%. Notice that -5 survives although it is the most negative weight in the matrix.W_P = [[3, 0], [0, -5]]، حيث ||W_P||_0 = 2 ونسبة الـ sparsity تساوي 50%. لاحظ أن -5 يبقى مع أنه الوزن الأكثر سالبية في المصفوفة.
This is Magnitude-based pruning, and the slide is honest about its status: it is a heuristic criterion. The assumption is that a weight far from zero contributes more to the output, and therefore to the loss, than a weight near zero. Han et al. (NeurIPS 2015) used exactly this threshold rule to produce the 9x and 13x reductions quoted in the first concept, which is strong evidence that the assumption is usually good enough. It is not the only score. Lecture 04-1, part 05, adds scaling factors such as batch-norm gammas for whole channels, and part 06 adds second-order saliency from Optimal Brain Damage, the percentage of zero activations, and regression-based selection. All of them plug into the same three steps: score, sort, keep the top N.
هذا هو الـ magnitude-based pruning، والشريحة صريحة بشأن طبيعته: إنه معيار تقريبي (heuristic). الافتراض أن الوزن البعيد عن الصفر يساهم في المخرجات، وبالتالي في الخسارة، أكثر من الوزن القريب من الصفر. استخدم Han et al. (NeurIPS 2015) قاعدة العتبة هذه بالضبط للوصول إلى التخفيضين 9x و13x المذكورين في المفهوم الأول، وهذا دليل قوي على أن الافتراض جيد بما يكفي في أغلب الأحوال. لكنه ليس الدرجة الوحيدة. تضيف المحاضرة 04-1 في جزئها 05 عوامل القياس (scaling factors) مثل قيم gamma في الـ batch-norm للقنوات الكاملة، ويضيف الجزء 06 أهمية الرتبة الثانية (second-order saliency) من Optimal Brain Damage، ونسبة التنشيطات الصفرية (zero activations)، والاختيار المعتمد على الانحدار (regression). وكلها تدخل في الخطوات الثلاث نفسها: أعطِ درجة، ثم رتّب، ثم احتفظ بأعلى N.
The shape of what is removedشكل ما يُحذف
Scoring weights one at a time and zeroing the smallest gives the pattern the slide calls fine-grained: zeros scattered wherever the small weights happened to be. The pruned network figure on that slide, again from Han et al., shows synapses vanishing at arbitrary positions and whole neurons disappearing once every synapse into them, or every synapse out of them, is gone. Fine-grained removal has the most freedom, since any index may be pruned, and that freedom is what buys it the highest compression ratios. The cost is that the survivors no longer form a dense block. Their positions must be stored as indices, and the hardware needs a sparse kernel that skips the holes. Mao et al. (2017) measured the other end of the trade: coarse-grained pruning reaches a sparsity similar to unstructured pruning without losing accuracy, needs far fewer indices, and saves about 2x the memory references compared with fine-grained sparsity.
إعطاء درجة لكل وزن على حدة وجعل الأصغر صفرًا ينتج النمط الذي تسميه الشريحة fine-grained (دقيق): أصفار متناثرة أينما صادف أن كانت الأوزان الصغيرة. شكل الشبكة بعد التقليم في تلك الشريحة، وهو أيضًا من Han et al.، يُظهر وصلات (synapses) تختفي في مواقع عشوائية، وعصبونات كاملة تختفي بمجرد أن تزول كل الوصلات الداخلة إليها أو كل الوصلات الخارجة منها. الحذف الدقيق يملك أكبر قدر من الحرية، لأن أي فهرس يمكن تقليمه، وهذه الحرية هي التي تمنحه أعلى نسب الضغط. الثمن أن الأوزان الباقية لم تعد تشكّل كتلة كثيفة (dense block). يجب تخزين مواقعها على شكل فهارس (indices)، ويحتاج العتاد إلى نواة حسابية متناثرة (sparse kernel) تتخطى الفراغات. قاس Mao et al. (2017) الطرف الآخر من هذه المقايضة: التقليم الخشن (coarse-grained) يصل إلى sparsity قريبة من التقليم غير المنتظم (unstructured) دون خسارة في الدقة، ويحتاج إلى فهارس أقل بكثير، ويوفّر نحو 2x من مرات الوصول إلى الذاكرة (memory references) مقارنة بالـ sparsity الدقيقة.
| Levelالمستوى | What is removedما الذي يُحذف | Flexibilityالمرونة | Hardware friendlinessملاءمة العتاد |
|---|---|---|---|
| Fine-grainedدقيق (Fine-grained) | Single weights at arbitrary positionsأوزان منفردة في مواقع عشوائية | Highestالأعلى | Needs stored indices and sparse kernelsيحتاج إلى تخزين الفهارس (indices) وأنوية حسابية متناثرة (sparse kernels) |
| Pattern-basedقائم على نمط (Pattern-based) | Weights in a fixed pattern, such as M:N (for example 2:4)أوزان بنمط ثابت مثل M:N (مثلًا 2:4) | Highعالية | Regular enough for special hardware supportمنتظم بما يكفي لدعم عتادي خاص |
| Vector-levelعلى مستوى المتجه (Vector-level) | One 1-D row of a kernel, W[o, i, r, :]صف أحادي البعد واحد من النواة، W[o, i, r, :] | Mediumمتوسطة | Moderate, fewer indices per blockمتوسطة، فهارس أقل لكل كتلة |
| Kernel-levelعلى مستوى النواة (Kernel-level) | One whole k x k kernelنواة كاملة واحدة بحجم k x k | Lowerأقل | Good, whole blocks disappearجيدة، تختفي كتل كاملة |
| Channel-levelعلى مستوى القناة (Channel-level) | A whole filter and its output channelمرشّح (filter) كامل مع قناته الخارجة | Lowestالأدنى | Best, the layer simply gets narrowerالأفضل، الطبقة ببساطة تصبح أضيق |
That ladder is the Pruning granularity axis, and the two ends pull against each other. Irregular patterns give the criterion freedom and therefore compression; regular patterns give the hardware dense blocks and therefore speed. Every design choice later in this lecture sits somewhere on this axis, and the 2:4 pattern of the tensor-core part is the industry's attempt to sit in both places at once.
هذا السلّم هو محور الـ pruning granularity (درجة تفصيل التقليم)، وطرفاه يتجاذبان في اتجاهين متعاكسين. الأنماط غير المنتظمة تعطي المعيار حرية، وبالتالي ضغطًا أكبر؛ والأنماط المنتظمة تعطي العتاد كتلًا كثيفة، وبالتالي سرعة أكبر. كل قرار تصميمي لاحق في هذه المحاضرة يقع في مكان ما على هذا المحور، ونمط 2:4 في جزء الـ tensor cores هو محاولة الصناعة للوقوف في المكانين معًا.
Recall
Weights 3, -2, 1, -5, keep half by magnitude: what survives and what is ||W_P||_0?الأوزان 3 و -2 و 1 و -5، احتفظ بنصفها حسب المقدار (magnitude): ما الذي يبقى، وما قيمة ||W_P||_0؟
Quick checkاختبار سريع
Applying Importance = |W| to 3, -2, 1, -5 and keeping half, which weights survive?عند تطبيق Importance = |W| على الأوزان 3 و -2 و 1 و -5 والاحتفاظ بنصفها، أي الأوزان تبقى؟
The coarse end of the ladder deserves one concrete picture, because it explains a sentence that students often quote without understanding: Neuron pruning is coarse-grained weight pruning. Slide 6 draws both cases, the linear layer and the convolution layer, and the same picture in matrix form makes the sentence obvious.
الطرف الخشن من السلّم يستحق صورة واحدة ملموسة، لأنها تشرح جملة يقتبسها الطلاب كثيرًا دون فهم: الـ neuron pruning (تقليم العصبونات) هو تقليم أوزان خشن (coarse-grained). ترسم الشريحة 6 الحالتين، الطبقة الخطية (linear layer) وطبقة الالتفاف (convolution layer)، والصورة نفسها في شكل مصفوفة تجعل هذه الجملة بديهية.
Removing a neuron is removing a rowحذف عصبون هو حذف صف
A linear layer computes y = W x with W of shape out x in. Output neuron i is nothing more than row i of W: its incoming weights are the entries of that row, and its output is that row's dot product with x. Deleting the neuron therefore deletes the whole row at once, which is the white stripe in the slide's weight matrix, and the next layer loses the matching column because that input no longer exists. That is neuron pruning, and it is weight pruning where the removed set is a structured block of in weights chosen together rather than one weight at a time. Lecture 04-1, part 06, first drew this equivalence next to Optimal Brain Damage.
الطبقة الخطية تحسب y = W x حيث شكل W هو out x in. العصبون الخارج i ليس أكثر من الصف i في W: أوزانه الداخلة هي عناصر ذلك الصف، ومخرجه هو حاصل الضرب النقطي لذلك الصف مع x. لذلك فإن حذف العصبون يحذف الصف كله دفعة واحدة، وهو الشريط الأبيض في مصفوفة الأوزان في الشريحة، وتفقد الطبقة التالية العمود المقابل لأن ذلك المدخل لم يعد موجودًا. هذا هو تقليم العصبونات، وهو تقليم أوزان تكون فيه المجموعة المحذوفة كتلة منتظمة من in وزنًا تُختار معًا، لا وزنًا واحدًا في كل مرة. رسمت المحاضرة 04-1، الجزء 06، هذا التكافؤ أول مرة بجانب Optimal Brain Damage.
The convolution version is the same idea one dimension up. A conv layer holds weights of shape C_out x C_in x k x k. Output channel j is produced by filter j, which is the slice of all C_in kernels that feed it. Deleting a channel deletes that entire filter, the two dashed blocks in the slide's stack of six filters and the two white rows of kernels in its weight grid (two of six output channels removed). That is Channel pruning, and its reward is that nothing sparse is left behind: the layer simply has C_out minus the pruned count of channels and runs on the same dense kernels as before.
نسخة الالتفاف هي الفكرة نفسها ببُعد إضافي. طبقة الـ conv تحمل أوزانًا شكلها C_out x C_in x k x k. القناة الخارجة j ينتجها المرشّح j، وهو الشريحة المكوّنة من كل الأنوية (kernels) الـ C_in التي تغذّيها. حذف قناة يحذف ذلك المرشّح بالكامل، وهما الكتلتان المنقّطتان في رزمة المرشّحات الستة في الشريحة، والصفّان الأبيضان من الأنوية في شبكة أوزانها (حُذفت قناتان خارجتان من ست). هذا هو الـ channel pruning، ومكافأته أنه لا يترك خلفه أي شيء متناثر: الطبقة ببساطة يصبح فيها C_out ناقص عدد القنوات المقلّمة، وتعمل على الأنوية الحسابية الكثيفة (dense kernels) نفسها كما كانت من قبل.
| Workالعمل | Model and dataالنموذج والبيانات | Resultالنتيجة |
|---|---|---|
| Li et al., ICLR 2017Li et al., ICLR 2017 | VGG-16, CIFAR-10VGG-16, CIFAR-10 | Up to 34% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 34% |
| Li et al., ICLR 2017Li et al., ICLR 2017 | ResNet-110, CIFAR-10ResNet-110, CIFAR-10 | Up to 38% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 38% |
| He et al., ICCV 2017He et al., ICCV 2017 | VGG-16VGG-16 | 5x speed-up, +0.3% errorتسريع 5x، مع زيادة في الخطأ +0.3% |
Five questions, three answeredخمسة أسئلة، أُجيب عن ثلاثة منها
The outline that opens this deck on slide 2, and returns on slide 7 to close this part, lists five questions, and the same outline appeared three times in lecture 04-1. It is the map of both lectures, so it is worth knowing where each question was answered. The formulation above answers the first. Granularity, the pattern of removal, was answered in 04-1. Criterion, the score used to rank weights, was also answered in 04-1. What remains open is how many weights each layer should lose, and how to recover the accuracy once they are gone.
المخطط الذي يفتتح هذا العرض في الشريحة 2، ويعود في الشريحة 7 ليختم هذا الجزء، يسرد خمسة أسئلة، وقد ظهر المخطط نفسه ثلاث مرات في المحاضرة 04-1. إنه خريطة المحاضرتين، لذلك يستحق أن تعرف أين أُجيب عن كل سؤال. الصياغة أعلاه تجيب عن السؤال الأول. ودرجة التفصيل (granularity)، أي نمط الحذف، أُجيب عنها في 04-1. والمعيار (criterion)، أي الدرجة المستخدمة لترتيب الأوزان، أُجيب عنه أيضًا في 04-1. ما بقي مفتوحًا هو كم وزنًا يجب أن تفقد كل طبقة، وكيف نستعيد الدقة بعد حذفها.
| Questionالسؤال | Asksماذا يسأل | Answered inأين أُجيب عنه |
|---|---|---|
| Introductionالمقدمة (Introduction) | What is pruning and how do we formulate it?ما الـ pruning وكيف نصوغه رياضيًا؟ | Lecture 04-1, part 01, and this partالمحاضرة 04-1، الجزء 01، وهذا الجزء |
| Granularityدرجة التفصيل (Granularity) | In what pattern should weights be removed?بأي نمط يجب أن تُحذف الأوزان؟ | Lecture 04-1, parts 03 and 04المحاضرة 04-1، الجزءان 03 و04 |
| Criterionالمعيار (Criterion) | Which synapses or neurons should go?أي الوصلات (synapses) أو العصبونات يجب أن تُحذف؟ | Lecture 04-1, parts 05 and 06المحاضرة 04-1، الجزءان 05 و06 |
| Ratioالنسبة (Ratio) | What target sparsity should each layer get?ما نسبة الـ sparsity المستهدفة لكل طبقة؟ | This lecture, parts 02 to 05هذه المحاضرة، الأجزاء من 02 إلى 05 |
| Fine-tune or trainإعادة الضبط أو التدريب (Fine-tune or train) | How do we recover the accuracy we lost?كيف نستعيد الدقة التي فقدناها؟ | This lecture, part 06هذه المحاضرة، الجزء 06 |
On slide 2 both open questions, ratio and fine-tuning, are highlighted in yellow. On slide 7, which closes this part, ratio turns green while fine-tuning stays yellow: ratio is being opened now, fine-tuning is still queued. The outline also under-sells the deck. After the five questions, parts 07 onward add a story the list never mentions, how EIE, 2:4 sparse tensor cores and sparse convolution engines turn the zeros produced by pruning into real speed and energy savings on hardware.
في الشريحة 2 يظهر السؤالان المفتوحان، النسبة (ratio) وإعادة الضبط (fine-tuning)، مظللين بالأصفر. وفي الشريحة 7، التي تختم هذا الجزء، تتحول النسبة إلى الأخضر بينما يبقى الـ fine-tuning أصفر: النسبة تُفتح الآن، والـ fine-tuning لا يزال في الانتظار. والمخطط أيضًا لا يعطي العرض حقه. فبعد الأسئلة الخمسة، تضيف الأجزاء من 07 فصاعدًا قصة لا تذكرها القائمة أبدًا: كيف تحوّل EIE وtensor cores المتناثرة بنمط 2:4 ومحركات الالتفاف المتناثر (sparse convolution engines) الأصفار الناتجة عن التقليم إلى سرعة حقيقية وتوفير فعلي في الطاقة على العتاد.
Quick checkاختبار سريع
Removing one neuron from a linear layer deletes what from its weight matrix?حذف عصبون واحد من طبقة خطية يحذف ماذا من مصفوفة أوزانها؟
Recall
What does removing one neuron of a linear layer do to W, and one channel of a conv layer?ماذا يفعل حذف عصبون واحد من طبقة خطية بالمصفوفة W، وماذا يفعل حذف قناة واحدة من طبقة conv؟
Recall
Which of the five questions did 04-1 answer, and which does 04-2 answer?أي الأسئلة الخمسة أجابت عنها 04-1، وأيها تجيب عنها 04-2؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Pruning: minimize L(x; W_P) subject to ||W_P||_0 <= N, where N is a budget on nonzeros.الـ Pruning: نقلّل L(x; W_P) بشرط ||W_P||_0 <= N، حيث N ميزانية لعدد القيم غير الصفرية.
- ||.||_0 counts nonzeros. It is not a norm and has no gradient, so every criterion is a heuristic proxy for the change in L.الرمز ||.||_0 يعدّ القيم غير الصفرية. ليس معيارًا (norm) وليس له تدرّج (gradient)، لذلك كل معيار للتقليم هو تقريب heuristic لمقدار التغيّر في L.
- Slide 3 mixes < N with <= N and W_p with W_P. Read <= N and one matrix.الشريحة 3 تخلط بين < N و <= N، وبين W_p و W_P. اقرأها على أنها <= N ومصفوفة واحدة.
- Magnitude criterion: Importance = |W|. Weights 3, -2, 1, -5 at 50% keep 3 and -5.معيار المقدار: Importance = |W|. من الأوزان 3 و -2 و 1 و -5 عند نسبة 50% نُبقي 3 و -5.
- Granularity runs from fine-grained (flexible, index heavy) to channel (regular, dense-friendly).درجة التفصيل (granularity) تمتد من الدقيق fine-grained (مرن لكنه يحتاج فهارس كثيرة) إلى مستوى القناة channel (منتظم ومناسب للحساب الكثيف dense).
- Neuron pruning removes a row of W. Channel pruning removes a filter. Both are coarse-grained weight pruning.تقليم العصبون (neuron pruning) يحذف صفًّا من W. وتقليم القناة (channel pruning) يحذف مرشّحًا (filter) كاملًا. كلاهما تقليم أوزان خشن (coarse-grained).
- 04-1 settled formulation, granularity and criterion. 04-2 answers ratio and fine-tuning, then adds sparse hardware.حسمت المحاضرة 04-1 الصياغة ودرجة التفصيل والمعيار. وتجيب 04-2 عن النسبة (ratio) وإعادة الضبط (fine-tuning)، ثم تضيف العتاد المخصص للمصفوفات المتناثرة (sparse hardware).
Sourcesالمصادر
- Learning both Weights and Connections for Efficient Neural NetworkPaperNeurIPS 2015, Han, Pool, Tran and DallyMagnitude threshold pruning with the train, prune, retrain loop; AlexNet 61M to 6.7M (9x), VGG-16 138M to 10.3M (13x).تقليم بعتبة المقدار (magnitude threshold) مع حلقة التدريب ثم التقليم ثم إعادة التدريب (train, prune, retrain)؛ AlexNet من 61M إلى 6.7M (9x)، وVGG-16 من 138M إلى 10.3M (13x).(opens in a new tab)(يفتح في تبويب جديد)
- Deep Learning, chapter 2: Linear Algebra, section 2.5 NormsBookMIT Press, Goodfellow, Bengio and CourvilleThe so-called L0 norm is incorrect terminology: the nonzero count does not scale with its argument, so it is not a norm.تسمية L0 norm مصطلح غير صحيح: عدد القيم غير الصفرية لا يتناسب مع مدخله عند ضربه في ثابت، لذلك ليس معيارًا (norm).(opens in a new tab)(يفتح في تبويب جديد)
- Learning Sparse Neural Networks through L0 RegularizationPaperICLR 2018, Louizos, Welling and KingmaStates that the L0 norm of the weights is non-differentiable, the reason it cannot be optimized by gradient descent.تنص على أن الـ L0 norm للأوزان غير قابل للاشتقاق، وهذا سبب عدم إمكان تحسينه بالـ gradient descent.(opens in a new tab)(يفتح في تبويب جديد)
- Optimal Brain DamagePaperNIPS 1989, LeCun, Denker and SollaSecond-derivative saliency as a criterion for removing weights.الأهمية المبنية على المشتقة الثانية (second-derivative saliency) معيارًا لحذف الأوزان.(opens in a new tab)(يفتح في تبويب جديد)
- Exploring the Regularity of Sparse Structure in Convolutional Neural NetworksPaperarXiv 2017, Mao et al.Granularity spectrum, index saving, and about 2x fewer memory references for coarse-grained sparsity.طيف درجات التفصيل (granularity)، والتوفير في الفهارس (indices)، وعدد أقل بنحو 2x من مرات الوصول إلى الذاكرة (memory references) في الـ sparsity الخشنة (coarse-grained).(opens in a new tab)(يفتح في تبويب جديد)
- Pruning Filters for Efficient ConvNetsPaperICLR 2017, Li, Kadav, Durdanovic, Samet and GrafWhole filters removed with their feature maps; FLOP reductions of up to 34% on VGG-16 and 38% on ResNet-110 for CIFAR-10 with dense BLAS.حذف مرشّحات (filters) كاملة مع خرائط السمات (feature maps) التابعة لها؛ تخفيض في الـ FLOPs يصل إلى 34% على VGG-16 و38% على ResNet-110 على CIFAR-10 باستخدام dense BLAS.(opens in a new tab)(يفتح في تبويب جديد)
- Channel Pruning for Accelerating Very Deep Neural NetworksPaperICCV 2017, He, Zhang and SunLASSO-based channel selection; 5x speed-up on VGG-16 with a 0.3% increase in error.اختيار القنوات بالاعتماد على LASSO؛ تسريع 5x على VGG-16 مع زيادة في الخطأ قدرها 0.3%.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024DocsMIT HAN Lab, Song HanLectures 3 and 4, Pruning and Sparsity parts I and II, the deck these COE 592 slides follow.المحاضرتان 3 و4، Pruning and Sparsity الجزءان I و II، وهو العرض الذي تتبعه شرائح COE 592 هذه.(opens in a new tab)(يفتح في تبويب جديد)