Majid Al-RaimiSecond-order, activation and regression criteriaمعايير الرتبة الثانية والتنشيط والانحدار

COE 592Lecture 4.1المحاضرة 4.1Part 06الجزء 06

Second-order, activation and regression criteriaمعايير الرتبة الثانية والتنشيط والانحدار

Optimal Brain Damage's Taylor-expansion importance 1/2 h_ii w_i^2, neuron pruning as coarse-grained weight pruning, APoZ activation-sparsity scoring, and regression-based channel pruning that minimizes layer output reconstruction error.أهمية Optimal Brain Damage المبنية على مفكوك تايلور 1/2 h_ii w_i^2، وتقليم العصبونات بوصفه تقليمًا خشنًا للأوزان، وتقييم تناثر التنشيط APoZ، وتقليم القنوات القائم على الانحدار الذي يقلل خطأ إعادة بناء مخرج الطبقة.

Conceptsالمفاهيم
6
Slidesالشرائح
34-43
Readingمدة القراءة
36 min36 دقيقة
Understoodما فهمته
0/6 conceptsمفاهيم

Why this part mattersلماذا يهمّ هذا الجزء

Part 05 ranked weights by their absolute value and nothing else. That rule cannot tell a small weight sitting in a steep valley of the loss from a small weight resting on a flat plain, and only one of those two is safe to delete. This part gives you three criteria that look past the weight value to what actually happens when the weight is gone.

The first reads the curvature of the loss: Optimal Brain Damage from 1989, the root of the SparseGPT-style methods that prune large language models today. The second reads the activations: APoZ, the cheapest data-driven structured criterion you can run before deploying on an embedded board. The third reads the layer output itself: regression-based channel pruning, the basis of the pipelines used to shrink networks for edge accelerators. All three are standard exam derivations, and the reasoning behind them is what you will reuse when your research project has to justify a pruning choice.

رتّب الجزء 05 الأوزان بحسب قيمتها المطلقة ولا شيء غير ذلك. هذه القاعدة لا تستطيع التمييز بين وزن صغير يقع في وادٍ شديد الانحدار من سطح الخسارة ووزن صغير يستقر على سهل منبسط، وواحد فقط من هذين الوزنين يمكن حذفه بأمان. يقدّم لك هذا الجزء ثلاثة معايير تنظر إلى ما وراء قيمة الوزن، أي إلى ما يحدث فعلًا حين يختفي الوزن.

المعيار الأول يقرأ انحناء دالة الخسارة: Optimal Brain Damage من عام 1989، وهو أصل الطرق على نمط SparseGPT التي تقلّم النماذج اللغوية الكبيرة اليوم. المعيار الثاني يقرأ التنشيطات (activations): APoZ، وهو أرخص معيار هيكلي (structured) قائم على البيانات يمكنك تشغيله قبل النشر على لوحة مدمجة. المعيار الثالث يقرأ مخرجات الطبقة نفسها: التقليم القائم على الانحدار لاختيار القنوات (regression-based channel pruning)، وهو أساس خطوط المعالجة المستخدمة لتصغير الشبكات من أجل مسرّعات الحافة (edge accelerators). الثلاثة كلها اشتقاقات امتحانية معتادة، والمنطق الذي يقف خلفها هو ما ستعيد استخدامه حين يحتاج مشروعك البحثي إلى تبرير اختيار طريقة تقليم.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Derive the OBD importance 1/2 h_ii w_i^2 from the Taylor expansion and name the assumption that removes each term.تشتق أهمية OBD وهي 1/2 h_ii w_i^2 من مفكوك تايلور، وتسمّي الافتراض الذي يحذف كل حد.
  2. Explain why magnitude pruning is OBD with a constant Hessian diagonal, and show a case where the two rankings disagree.تشرح لماذا يُعدّ التقليم بالمقدار (magnitude pruning) حالة من OBD يكون فيها قطر الـ Hessian ثابتًا، وتعرض حالة يختلف فيها الترتيبان.
  3. Compute APoZ for a channel from its activation maps and decide which channel to prune.تحسب APoZ لقناة من خرائط تنشيطها، وتقرر أي قناة تُقلَّم.
  4. State the regression-based channel pruning objective, its L0 constraint and the two alternating LASSO and least-squares steps.تكتب هدف التقليم القائم على الانحدار لاختيار القنوات، وقيد L0 فيه، والخطوتين المتناوبتين: LASSO ثم المربعات الصغرى (least squares).
  5. Place each criterion in the reference list and say what data it needs.تضع كل معيار في مكانه من قائمة المراجع، وتذكر ما يحتاجه من بيانات.

Start with a trained network and its loss L(x; W). Setting one weight to zero moves the parameter vector from W to W_P = W + δW, where δW is zero everywhere except at the pruned position, where δw_i = -w_i. The question every criterion in this part is trying to answer is simple: how much does the loss move? You could answer it exactly by re-evaluating the loss after each candidate deletion, but LeCun, Denker and Solla call that approach prohibitively laborious, and for a network with thousands of weights it is. Second-order pruning builds a local model of the loss instead.

ابدأ بشبكة مدرَّبة ودالة خسارتها L(x; W). جعل وزن واحد صفرًا ينقل متجه المعاملات من W إلى W_P = W + δW، حيث δW صفر في كل مكان عدا الموضع المقلَّم، وفيه δw_i = -w_i. السؤال الذي يحاول كل معيار في هذا الجزء أن يجيب عنه بسيط: بكم تتحرك الخسارة؟ يمكنك الإجابة بدقة بإعادة حساب الخسارة بعد كل عملية حذف مرشَّحة، لكن LeCun وDenker وSolla يصفون هذا الأسلوب بأنه مُرهِق إلى حد يمنع استخدامه، وهو كذلك فعلًا لشبكة فيها آلاف الأوزان. لذلك يبني second-order pruning نموذجًا محليًا للخسارة بدلًا من ذلك.

One weight before the general case. A weight sits at w = 0.5 in a valley of the loss surface given by L(w) = 1 + 2(w - 0.5)². Setting it to zero walks back to w = 0 and raises the loss from 1 to 1.5, and that rise is exactly ½ h w² with curvature h = 4: the gradient at the bottom of the valley is zero, so the first-order term contributes nothing and the curvature term contributes everything. Now scale the picture up to a whole parameter vector. The local model is a Taylor expansion of the loss around the trained point. Perturbing the weights by δW changes the loss by a first-order slope term, a second-order curvature term, and a remainder that shrinks as the cube of the perturbation.

لنبدأ بوزن واحد قبل الحالة العامة. يقع وزن عند w = 0.5 في وادٍ من سطح الخسارة معطى بالعلاقة L(w) = 1 + 2(w - 0.5)². جعله صفرًا يعيده إلى w = 0 ويرفع الخسارة من 1 إلى 1.5، وهذه الزيادة تساوي تمامًا ½ h w² مع انحناء h = 4: الميل عند قاع الوادي صفر، فحد الدرجة الأولى لا يساهم بشيء وحد الانحناء يساهم بكل شيء. الآن كبّر الصورة إلى متجه معاملات كامل. النموذج المحلي هو Taylor expansion للخسارة حول النقطة المدرَّبة. تحريك الأوزان بمقدار δW يغيّر الخسارة بحد ميل من الدرجة الأولى، وحد انحناء من الدرجة الثانية، وباقٍ يصغر بمكعّب مقدار الاضطراب.

δL=L(x;W+δW)−L(x;W)=∑igi δwi+12∑ihii δwi2+12∑i≠jhij δwi δwj+O ⁣(∥δW∥3)\delta L = L(x; W + \delta W) - L(x; W) = \sum_i g_i\,\delta w_i + \frac{1}{2}\sum_i h_{ii}\,\delta w_i^2 + \frac{1}{2}\sum_{i \neq j} h_{ij}\,\delta w_i\,\delta w_j + O\!\left(\lVert \delta W \rVert^3\right)
Second-order Taylor expansion of the loss change under a weight perturbation, new loss minus oldمفكوك Taylor من الرتبة الثانية لتغير الخسارة تحت اضطراب في الأوزان، الخسارة الجديدة ناقص القديمة
gi=∂L∂wi,hij=∂2L∂wi ∂wjg_i = \frac{\partial L}{\partial w_i}, \qquad h_{ij} = \frac{\partial^2 L}{\partial w_i\,\partial w_j}
The gradient entries and the Hessian entriesعناصر التدرّج وعناصر مصفوفة Hessian

Read the four pieces one at a time. The first sum is the slope: how fast the loss rises if you nudge each weight on its own. The second sum is the self-curvature: how quickly that slope itself changes along each weight's own axis, weighted by the square of the nudge. The third sum is the cross-curvature: whether moving weight i also tilts the loss along weight j. The last piece is everything the quadratic picture misses. The Hessian is the matrix that holds the second and third pieces together: its diagonal h_ii feeds the self-curvature sum and its off-diagonal h_ij feeds the cross terms.

اقرأ الأجزاء الأربعة واحدًا تلو الآخر. المجموع الأول هو الميل: مدى سرعة ارتفاع الخسارة إذا حرّكت كل وزن وحده. المجموع الثاني هو الانحناء الذاتي: مدى سرعة تغيّر هذا الميل نفسه على امتداد محور كل وزن، مضروبًا في مربع مقدار التحريك. المجموع الثالث هو الانحناء التقاطعي: هل تحريك الوزن i يُميل الخسارة أيضًا على امتداد الوزن j؟ والجزء الأخير هو كل ما تفوته الصورة التربيعية. الـ Hessian هو المصفوفة التي تجمع الجزأين الثاني والثالث: قطرها h_ii يغذّي مجموع الانحناء الذاتي، وعناصرها خارج القطر h_ij تغذّي الحدود التقاطعية.

Goodfellow, Bengio and Courville define the Hessian exactly this way, as the matrix with entries ∂²f/(∂x_i ∂x_j), and note that it is symmetric wherever the second partials are continuous. The cross sum runs over ordered pairs i ≠ j, so each unordered pair appears twice, once as (i, j) and once as (j, i); the one half in front is the second-order Taylor coefficient from ½ δWᵀ H δW, not a symmetry correction. Because H is symmetric the same term can be written without the one half as Σ_{i < j} h_ij δw_i δw_j. They also use this same second-order expansion to derive Newton's method, so the expression on the slide is not a pruning trick: it is the standard local model of any smooth function.

يعرّف Goodfellow وBengio وCourville الـ Hessian بهذه الطريقة بالضبط، أي المصفوفة التي عناصرها ∂²f/(∂x_i ∂x_j)، ويلاحظون أنها متماثلة (symmetric) حيثما كانت المشتقات الجزئية الثانية متصلة. المجموع التقاطعي يمر على الأزواج المرتبة i ≠ j، فيظهر كل زوج غير مرتب مرتين، مرة بصورة (i, j) ومرة بصورة (j, i)؛ والنصف الموجود في المقدمة هو معامل تايلور من الدرجة الثانية القادم من ½ δWᵀ H δW، وليس تصحيحًا بسبب التماثل. ولأن H متماثلة، يمكن كتابة الحد نفسه دون النصف بصورة Σ_{i < j} h_ij δw_i δw_j. ويستخدم المؤلفون أيضًا المفكوك نفسه من الدرجة الثانية لاشتقاق طريقة نيوتن (Newton's method)، فالتعبير الموجود في الشريحة ليس حيلة خاصة بالتقليم: إنه النموذج المحلي القياسي لأي دالة ملساء.

How big the Hessian is for the OBD zip-code network (LeCun et al., 1989, p. 600)حجم الـ Hessian لشبكة الرموز البريدية في OBD (LeCun وزملاؤه، 1989، ص 600)

Parametersالمعاملات
about 2600 (2578 free parameters)نحو 2600 (2578 معاملًا حرًا)
Full Hessian entriesعناصر الـ Hessian الكامل
about 6.5 × 10⁶, the figure the paper quotesنحو 6.5 × 10⁶، وهو الرقم الذي تذكره الورقة
Diagonal entriesعناصر القطر
about 2600, one per parameterنحو 2600، عنصر واحد لكل معامل

The table is the reason the rest of this part exists. Even a 1989 network with about 2600parameters has millions of Hessian entries, and a modern network with 10⁸ weights would have 10¹⁶. Nobody computes that matrix. The whole art of second-order pruning is deciding which of its entries you can afford to ignore.

هذا الجدول هو سبب وجود بقية هذا الجزء. حتى شبكة من عام 1989 فيها نحو 2600 معامل تملك ملايين العناصر في الـ Hessian، وشبكة حديثة فيها 10⁸ وزن سيكون لديها 10¹⁶ عنصر. لا أحد يحسب هذه المصفوفة. فن التقليم من الدرجة الثانية كله هو أن تقرر أي عناصرها يمكنك تحمّل تجاهله.

Recall

Write the second-order Taylor expansion of the loss change and name what each of its four pieces measures.اكتب مفكوك تايلور من الدرجة الثانية لتغيّر الخسارة، وسمِّ ما يقيسه كل جزء من أجزائه الأربعة.

δL = L(W + δW) - L(W) = Σ g_i δw_i + ½ Σ h_ii δw_i² + ½ Σ_{i ≠ j} h_ij δw_i δw_j + O(||δW||³). The first sum is the slope along each weight, the second is the curvature along each weight's own axis, the third is the cross-curvature between pairs of weights, and the remainder collects every term of third order and higher.
δL = L(W + δW) - L(W) = Σ g_i δw_i + ½ Σ h_ii δw_i² + ½ Σ_{i ≠ j} h_ij δw_i δw_j + O(||δW||³). المجموع الأول هو الميل على امتداد كل وزن، والثاني هو الانحناء على امتداد محور كل وزن نفسه، والثالث هو الانحناء التقاطعي بين أزواج الأوزان، والباقي يجمع كل الحدود من الدرجة الثالثة فما فوق.

Four terms is three too many. Optimal Brain Damage keeps the expansion usable by making three assumptions, and each one erases exactly one piece of the sum. The paper gives them names, the slide gives them plain-language bullets, and you should be able to match the two lists and say which term each one kills.

أربعة حدود تزيد ثلاثة عن الحاجة. يُبقي Optimal Brain Damage المفكوك قابلًا للاستخدام عبر ثلاثة افتراضات، وكل افتراض يمحو جزءًا واحدًا بالضبط من المجموع. الورقة تعطي هذه الافتراضات أسماء، والشريحة تعرضها بنقاط بلغة بسيطة، وعليك أن تستطيع المطابقة بين القائمتين وتقول أي حد يقضي عليه كل افتراض.

Three assumptions cross out three terms: the converged gradient, the cross-curvature and the cubic remainder. Only the diagonal curvature term survives.ثلاثة افتراضات تشطب ثلاثة حدود: الميل عند التقارب، والانحناء التقاطعي، والباقي التكعيبي. يبقى حد الانحناء القطري وحده.
OBD nameالاسم في OBDSlide wordingصياغة الشريحةTerm removedالحد المحذوفWhy it is allowedلماذا يُسمح به
Quadraticالتربيعي (Quadratic)L is nearly quadraticالخسارة L تربيعية تقريبًاO(||δW||³)O(||δW||³)Near the minimum the loss surface is well described by its curvature alone, so the cubic remainder is negligible.قرب القيمة الصغرى يصف الانحناء وحده سطح الخسارة وصفًا جيدًا، فيصبح الباقي التكعيبي مهملًا.
Extremalالطرفي (Extremal)Training has convergedالتدريب قد تقاربΣ gᵢ δwᵢΣ gᵢ δwᵢAt a local minimum every partial derivative is zero, so the whole first-order sum vanishes and every hᵢᵢ is non-negative.عند قيمة صغرى محلية تكون كل مشتقة جزئية صفرًا، فيتلاشى مجموع الدرجة الأولى كله، وتكون كل قيم hᵢᵢ غير سالبة.
Diagonalالقطري (Diagonal)Deletion errors are independentأخطاء الحذف مستقلة½ Σᵢ≠ⱼ hᵢⱼ δwᵢ δwⱼ½ Σᵢ≠ⱼ hᵢⱼ δwᵢ δwⱼThe cost of deleting several weights is taken as the sum of their individual costs, which is exactly what dropping the off-diagonal terms means.تُعدّ كلفة حذف عدة أوزان مساوية لمجموع كلفها المنفردة، وهذا بالضبط معنى إسقاط الحدود خارج القطر.
The three OBD approximations and what each removesافتراضات OBD التقريبية الثلاثة وما يحذفه كل منها

The extremal assumption does double duty. Because training stopped at a local minimum, the gradient is zero and the first sum disappears, but LeCun, Denker and Solla also point out that at a local minimum all the h_ii are non-negative, so any perturbation of the parameters will cause the loss to increase or stay the same. That single sentence is the source of the footnote on slide 36 that h_ii is non-negative, and it is what lets the surviving term serve as a cost rather than a signed change.

الافتراض الطرفي (extremal) يؤدي مهمتين. لأن التدريب توقف عند قيمة صغرى محلية، يكون الميل صفرًا فيختفي المجموع الأول، لكن LeCun وDenker وSolla يشيرون أيضًا إلى أن كل قيم h_ii عند القيمة الصغرى المحلية غير سالبة، فأي اضطراب في المعاملات سيجعل الخسارة تزيد أو تبقى كما هي. هذه الجملة الواحدة هي مصدر الحاشية في الشريحة 36 التي تقول إن h_ii غير سالبة، وهي ما يسمح للحد الباقي بأن يعمل ككلفة لا كتغيّر له إشارة.

What survives is the diagonal curvature term alone. Deleting weight i means setting it to zero and, in the paper's words, freezing it there, so the step along that axis has the size of the weight itself, |δw_i| = |w_i|. The squared terms of the expansion do not care about the sign of δw_i, so substitute and you have the OBD estimate of the loss increase.

ما يبقى هو حد الانحناء القطري وحده. حذف الوزن i يعني جعله صفرًا، وبتعبير الورقة تجميده هناك، فتكون الخطوة على ذلك المحور بحجم الوزن نفسه، |δw_i| = |w_i|. الحدود المربعة في المفكوك لا تهتم بإشارة δw_i، فعوّض وستحصل على تقدير OBD لزيادة الخسارة.

δLi=L(x;W)−L(x;WP∣wi=0)≈12hiiwi2\delta L_i = L(x; W) - L(x; W_P \mid w_i = 0) \approx \frac{1}{2} h_{ii} w_i^2
Loss change from deleting a single weight under the three OBD assumptionsتغير الخسارة عند حذف وزن واحد وفق افتراضات OBD الثلاثة
importancewi=∣δLi∣=12hiiwi2\text{importance}_{w_i} = \lvert \delta L_i \rvert = \frac{1}{2} h_{ii} w_i^2
OBD saliency. Remove the weights with the smallest values first.أهمية OBD (saliency). احذف الأوزان ذات القيم الأصغر أولًا.

The paper calls this quantity the saliency of a parameter, s_k = h_kk w_k² / 2 (the paper writes its parameter as u_k, the same variable as the w_k used on the slide and here), and the recipe is to delete the parameters with the lowest saliency. Notice what the formula says about a weight's importance: it is the product of two things, how large the weight is and how sharply the loss curves along that weight's axis. Magnitude pruning from part 05 kept only the first factor.

تسمي الورقة هذه الكمية saliency (البروز) للمعامل، s_k = h_kk w_k² / 2 (تكتب الورقة معاملها بالرمز u_k، وهو المتغير نفسه الذي يُكتب w_k في الشريحة وهنا)، والوصفة هي حذف المعاملات ذات البروز الأقل. لاحظ ما تقوله الصيغة عن أهمية الوزن: إنها حاصل ضرب شيئين، حجم الوزن ومدى حدة انحناء الخسارة على امتداد محور ذلك الوزن. أما التقليم بالمقدار في الجزء 05 فأبقى العامل الأول فقط.

Magnitude pruning is OBD with the curvature assumed constantالتقليم بالمقدار هو OBD مع افتراض أن الانحناء ثابت

Suppose every h_ii were the same number h. Then importance would be (h/2) w_i², and ranking weights by that value is exactly ranking them by |w_i|, since squaring and scaling by a positive constant preserve the order. So Magnitude-based pruning is OBD under a fourth, hidden assumption: that the loss curves equally steeply along every weight. The 1989 paper states its goal as moving beyond the approximation that magnitude equals saliency, and the point of a second-order criterion is to drop that assumption. The table below is a small case where doing so changes the answer.

افترض أن كل h_ii تساوي العدد نفسه h. عندها تصبح الأهمية (h/2) w_i²، وترتيب الأوزان بهذه القيمة هو بالضبط ترتيبها بحسب |w_i|، لأن التربيع والضرب في ثابت موجب يحافظان على الترتيب. إذن magnitude-based pruning هو OBD تحت افتراض رابع خفي: أن الخسارة تنحني بالحدة نفسها على امتداد كل وزن. تذكر ورقة 1989 أن هدفها هو تجاوز التقريب الذي يجعل المقدار مساويًا للبروز، والغاية من معيار من الدرجة الثانية هي التخلص من هذا الافتراض. الجدول التالي حالة صغيرة يغيّر فيها ذلك الإجابة.

Weightالوزنwᵢwᵢhᵢᵢhᵢᵢ|wᵢ||wᵢ|½ hᵢᵢ wᵢ²½ hᵢᵢ wᵢ²MagnitudeالمقدارOBDOBD
AA1.51.50.20.21.51.50.2250.225keepيُبقىpruneيُقلَّم
BB1.01.01.01.01.01.00.50.5keepيُبقىkeepيُبقى
CC-0.6-0.64.04.00.60.60.720.72keepيُبقىkeepيُبقى
DD0.50.58.08.00.50.51.01.0pruneيُقلَّمkeepيُبقى
EE0.20.22.02.00.20.20.040.04pruneيُقلَّمpruneيُقلَّم
Magnitude and OBD disagree on which two of five weights to pruneالمقدار وOBD يختلفان في أي وزنين من خمسة يُقلَّمان
Two weights rest on two loss valleys. Sliding each to zero raises the loss by half the curvature times the weight squared. The smaller weight in the steep valley costs twice as much as the larger weight on the flat one.وزنان يستقران في واديين من سطح الخسارة. إزاحة كل منهما إلى الصفر ترفع الخسارة بمقدار نصف الانحناء مضروبًا في مربع الوزن. الوزن الأصغر في الوادي الحاد يكلّف ضعف ما يكلّفه الوزن الأكبر في الوادي المنبسط.

Worked exampleمثال محلول

Five weights, two rankings, prune twoخمسة أوزان، ترتيبان، نقلّم اثنين

  1. Square each weightربّع كل وزن

    1.5² = 2.25, 1.0² = 1.0, (-0.6)² = 0.36, 0.5² = 0.25, 0.2² = 0.04. The sign of C disappears, as it does in |w|.
    1.5² = 2.25، 1.0² = 1.0، (-0.6)² = 0.36، 0.5² = 0.25، 0.2² = 0.04. تختفي إشارة C، كما تختفي في |w|.
  2. Multiply by the curvature and halveاضرب في الانحناء ثم خذ النصف

    A: ½ × 0.2 × 2.25 = 0.225, B: ½ × 1.0 × 1.0 = 0.5, C: ½ × 4.0 × 0.36 = 0.72, D: ½ × 8.0 × 0.25 = 1.0, E: ½ × 2.0 × 0.04 = 0.04.
    A: ½ × 0.2 × 2.25 = 0.225، B: ½ × 1.0 × 1.0 = 0.5، C: ½ × 4.0 × 0.36 = 0.72، D: ½ × 8.0 × 0.25 = 1.0، E: ½ × 2.0 × 0.04 = 0.04.
  3. Rank by each criterion, lowest firstرتّب بحسب كل معيار، من الأقل إلى الأعلى

    Magnitude: E, D, C, B, A. Saliency: E, A, B, C, D.
    المقدار (Magnitude): E, D, C, B, A. البروز (Saliency): E, A, B, C, D.
  4. Pruning two weightsتقليم وزنين

    Both criteria delete E. Magnitude then deletes D, the weight OBD rates as the most important of all five. OBD deletes A instead, the largest weight in the set, because it sits on almost flat ground.
    كلا المعيارين يحذف E. ثم يحذف معيار المقدار D، وهو الوزن الذي يعدّه OBD الأهم بين الخمسة كلها. أما OBD فيحذف A بدلًا منه، وهو أكبر وزن في المجموعة، لأنه يقع على أرض شبه منبسطة.
InteractiveتفاعليMagnitude versus OBD: same weights, two rankingsالمقدار مقابل OBD: الأوزان نفسها، وترتيبان
Weightw_ih_ii|w_i|½ h_ii w_i²mag rankmagnitudeobd rankobd
A1.50.2255keep2prune
B10.54keep3keep
C0.60.723keep4keep
D0.512prune5keep
E0.20.041prune1prune
Disagreementsمواضع الاختلاف2weightsrows with a stripe are pruned by one criterion and kept by the otherالصفوف المخططة يقلّمها أحد المعيارين ويحتفظ بها الآخر
Rank 1 meansالترتيب 1 يعنيlowestpruned firstset every h_ii equal and the two rankings coincide: magnitude is OBD with constant curvatureاجعل كل قيم h_ii متساوية فيتطابق الترتيبان: معيار المقدار هو OBD مع انحناء ثابت

Set every h_ii in the table to the same value and watch the two decision columns fall into line. Then give a small weight a large curvature and watch them split again. That is the entire relationship between the two criteria in one gesture.

اجعل كل h_ii في الجدول بالقيمة نفسها وراقب عمودي القرار وهما يتطابقان. ثم أعطِ وزنًا صغيرًا انحناءً كبيرًا وراقبهما يفترقان من جديد. هذه هي العلاقة كاملة بين المعيارين في حركة واحدة.

Why the slide says the Hessian is difficultلماذا تقول الشريحة إن الـ Hessian صعب

The full Hessian has n² entries, and the previous concept showed that this is out of reach even for a small network. OBD never computes it. The diagonal approximation means only the n entries h_ii are needed, and the paper derives a second back-propagation pass that computes them with, in its words, the same order of complexity as computing the gradient. Along the way it drops the terms involving the second derivative of the activation function, a Levenberg-Marquardt style approximation that gives guaranteed positive estimates of the second derivative. So the difficulty the slide flags is real for the full matrix and for networks with 10⁸ parameters, where even a diagonal pass over the whole training set is expensive, but it is not a reason OBD itself was impractical. Optimal Brain Surgeon (Hassibi and Stork, 1993) kept the cross terms by using the inverse of the full Hessian. SparseGPT (2023) makes second-order pruning practical at scale by solving layer-wise reconstruction problems with block-wise Hessian updates, which the final concept points to.

الـ Hessian الكامل فيه n² عنصر، وقد بيّن المفهوم السابق أن هذا بعيد المنال حتى لشبكة صغيرة. OBD لا يحسبه أبدًا. التقريب القطري يعني أن المطلوب فقط هو العناصر n وهي h_ii، وتشتق الورقة تمريرًا ثانيًا للانتشار العكسي يحسبها، بتعبيرها، بنفس رتبة تعقيد حساب الميل. وفي الطريق تُسقط الحدود التي تتضمن المشتقة الثانية لدالة التنشيط، وهو تقريب على نمط Levenberg-Marquardt يعطي تقديرات موجبة مضمونة للمشتقة الثانية. إذن الصعوبة التي تشير إليها الشريحة حقيقية بالنسبة للمصفوفة الكاملة وللشبكات ذات 10⁸ معامل، حيث يكون حتى التمرير القطري على كامل مجموعة التدريب مكلفًا، لكنها ليست سببًا في أن OBD نفسه كان غير عملي. أبقى Optimal Brain Surgeon (Hassibi وStork، 1993) على الحدود التقاطعية باستخدام معكوس الـ Hessian الكامل. ويجعل SparseGPT (2023) التقليم من الدرجة الثانية عمليًا على نطاق واسع بحل مسائل إعادة بناء على مستوى كل طبقة مع تحديثات للـ Hessian على شكل كتل (block-wise)، وهو ما يشير إليه المفهوم الأخير.

The recipe and what it achievedالوصفة وما حققته

The abstract on the slide states the motivation the formula serves. Deleting unimportant weights is a trade-off between network complexity and training-set error, and the paper expects better generalization, fewer training examples required and faster learning and classification from it. That is why the recipe below is framed as model selection, not only compression.

الملخص الموجود في الشريحة يذكر الدافع الذي تخدمه الصيغة. حذف الأوزان غير المهمة موازنة بين تعقيد الشبكة وخطأ مجموعة التدريب، وتتوقع الورقة من ذلك تعميمًا أفضل، وحاجة إلى أمثلة تدريب أقل، وتعلّمًا وتصنيفًا أسرع. لهذا تُصاغ الوصفة التالية على أنها اختيار للنموذج (model selection)، لا مجرد ضغط.

  1. Choose a reasonable network architecture.اختر معمارية شبكة معقولة.
  2. Train the network until reasonable convergence.درّب الشبكة حتى تتقارب تقاربًا معقولًا.
  3. Compute the second derivatives h_kk for each parameter.احسب المشتقات الثانية h_kk لكل معامل.
  4. Compute the saliencies s_k = h_kk w_k² / 2.احسب قيم البروز s_k = h_kk w_k² / 2.
  5. Sort the parameters by saliency and delete some low-saliency parameters.رتّب المعاملات بحسب البروز واحذف بعض المعاملات ذات البروز المنخفض.
  6. Return to step 2.عُد إلى الخطوة 2.

The loop back to training is the Iterative pruning and Fine-tuning pattern from part 02, thirty years earlier. The 1989 experiment applied it to a handwritten zip-code recognizer.

العودة إلى التدريب هي نمط iterative pruning وfine-tuning من الجزء 02، قبله بثلاثين عامًا. طبّقت تجربة 1989 هذا النمط على نظام للتعرف على الرموز البريدية المكتوبة بخط اليد.

Optimal Brain Damage results (LeCun, Denker and Solla, 1989)نتائج Optimal Brain Damage (LeCun وDenker وSolla، 1989)

Setupالإعداد
about 10⁵ connections controlled by 2578 free parameters, trained on roughly 9300 digits and tested on 3350نحو 10⁵ وصلة يتحكم فيها 2578 معاملًا حرًا، دُرّبت على نحو 9300 رقم واختُبرت على 3350
Prediction qualityجودة التنبؤ
The quadratic, extremal, diagonal estimate tracks the measured loss up to about 800 deleted parameters, roughly 30%; beyond that the cross terms and higher-order terms the approximation dropped start to matterالتقدير التربيعي الطرفي القطري يتبع الخسارة المقيسة حتى نحو 800 معامل محذوف، أي قرابة 30%؛ وبعد ذلك تبدأ الحدود التقاطعية والحدود الأعلى رتبة التي أسقطها التقريب في التأثير
After retrainingبعد إعادة التدريب
Up to 1500 parameters, about 60%, deleted with almost unchanged training and test errorحُذف حتى 1500 معامل، أي نحو 60%، مع بقاء خطأ التدريب والاختبار شبه ثابتين
Versus magnitudeمقارنة بالمقدار
Deleting in order of saliency causes a significantly smaller increase of the objective than deleting by magnitude (figure 1a)الحذف بترتيب البروز يسبب زيادة في دالة الهدف أصغر بكثير من الحذف بحسب المقدار (الشكل 1a)
Versus randomمقارنة بالحذف العشوائي
Random deletion was so much worse it could not be plotted on the same scaleكان الحذف العشوائي أسوأ بكثير إلى حد أنه لم يمكن رسمه على المقياس نفسه
Venueمكان النشر
Advances in Neural Information Processing Systems 2 (NIPS 1989), AT&T Bell Laboratories, Holmdel NJAdvances in Neural Information Processing Systems 2 (NIPS 1989)، مختبرات AT&T Bell Laboratories، Holmdel NJ

Quick checkاختبار سريع

Under OBD, which assumption removes the first-order gradient term from the Taylor expansion?في OBD، أي افتراض يحذف حد الميل من الدرجة الأولى من مفكوك تايلور؟

Quick checkاختبار سريع

Weight A has w = 1.0 and h = 1; weight B has w = 0.5 and h = 8. Which does OBD keep first?الوزن A فيه w = 1.0 وh = 1، والوزن B فيه w = 0.5 وh = 8. أيهما يُبقيه OBD أولًا؟

Recall

Why is magnitude pruning a special case of OBD?لماذا يُعد التقليم بالمقدار حالة خاصة من OBD؟

If every h_ii equals the same constant h, importance becomes (h/2) w_i², and ranking by that value is the same as ranking by |w_i|. OBD differs only by letting the curvature vary from weight to weight.
إذا كانت كل h_ii تساوي الثابت نفسه h، تصبح الأهمية (h/2) w_i²، والترتيب بهذه القيمة هو نفسه الترتيب بحسب |w_i|. لا يختلف OBD إلا بأنه يسمح للانحناء بأن يتغير من وزن لآخر.

Everything so far scored individual synapses. Take a linear layer with 5 inputs and 4 outputs, so its weight matrix has shape [4, 5]. Deleting the second output neuron does not zero one entry; it removes the entire row W[1, :], all 5 incoming weights at once, along with the edges drawn into that neuron on the slide, which is why the lower layer shows three circles with a gap where the fourth stood. The matrix becomes [3, 5], a smaller dense matrix, which is the reason Coarse-grained (structured) pruning gives real speedup without any sparse format.

كل ما سبق كان يقيّم وصلات (synapses) منفردة. خذ طبقة خطية لها 5 مدخلات و4 مخرجات، فتكون مصفوفة أوزانها بالشكل [4, 5]. حذف العصبون الثاني في المخرجات لا يجعل عنصرًا واحدًا صفرًا؛ بل يحذف الصف كاملًا W[1, :]، أي الأوزان الداخلة الـ 5 كلها دفعة واحدة، مع الحواف المرسومة الداخلة إلى ذلك العصبون في الشريحة، ولهذا تُظهر الطبقة السفلى ثلاث دوائر وفجوة في مكان الرابعة. تصبح المصفوفة [3, 5]، أي مصفوفة كثيفة أصغر، وهذا سبب أن coarse-grained pruning يعطي تسريعًا حقيقيًا دون أي صيغة تخزين متفرقة (sparse format).

That is the whole content of the sentence on the slide: Neuron pruning is coarse-grained weight pruning. In a convolution layer with weights of shape [c_o, c_i, k_h, k_w] (recall Convolution weight dimensions), deleting output channel o deletes W[o, :, :, :], one full row of c_i kernels in the slide's grid, where rows 3 and 5 of six filters are blanked out. It also deletes the corresponding map from the layer's output, and therefore the input channel o of every filter in the next layer, a point He et al. make explicitly in their figure. Channel pruning cuts twice.

هذا هو كل مضمون الجملة الموجودة في الشريحة: neuron pruning هو تقليم أوزان خشن الحبيبات. في طبقة التفاف أوزانها بالشكل [c_o, c_i, k_h, k_w] (تذكّر conv weight dimensions)، فإن حذف قناة المخرجات o يحذف W[o, :, :, :]، أي صفًا كاملًا من c_i نواة (kernel) في شبكة الشريحة، حيث يُفرَّغ الصفان 3 و5 من ستة مرشحات. ويحذف أيضًا الخريطة المقابلة من مخرجات الطبقة، وبالتالي قناة المدخلات o في كل مرشح من الطبقة التالية، وهي نقطة يذكرها He وزملاؤه صراحة في الشكل الخاص بهم. إذن channel pruning يقطع مرتين.

Unit removedالوحدة المحذوفةSlice deletedالشريحة المحذوفة من الموترWeights deletedالأوزان المحذوفةShape afterالشكل بعد الحذف
Output neuron of a linear layerعصبون مخرجات في طبقة خطيةW[o, :]W[o, :]One row: all incoming weights of that neuronصف واحد: كل الأوزان الداخلة إلى ذلك العصبون[c_o - 1, c_i][c_o - 1, c_i]
Output channel (filter) of a conv layerقناة مخرجات (مرشح) في طبقة التفافW[o, :, :, :]W[o, :, :, :]c_i kernels of k_h × k_w eachc_i نواة، كل منها بحجم k_h × k_w[c_o - 1, c_i, k_h, k_w][c_o - 1, c_i, k_h, k_w]
Input channel of the next conv layerقناة مدخلات في طبقة الالتفاف التاليةW[:, o, :, :]W[:, o, :, :]c_o kernels, one per filter, that read the removed mapc_o نواة، واحدة لكل مرشح، كانت تقرأ الخريطة المحذوفة[c_o, c_i - 1, k_h, k_w][c_o, c_i - 1, k_h, k_w]
What one removed unit takes with itما تأخذه معها وحدة واحدة محذوفة

The rule on the slide is then almost a tautology: the less useful the removed neurons are, the better the pruned network performs. The work is in defining useful. The Pruning criterion question has simply moved up one level of granularity, and part 05 already gave one answer, the L1 or L2 norm of the row or filter. The next two concepts give two answers that need no Hessian and no norm: look at the activations the neuron produces, or look at how well the layer output can be rebuilt without it.

القاعدة الموجودة في الشريحة تكاد تكون بديهية إذن: كلما قلّت فائدة العصبونات المحذوفة، كان أداء الشبكة المقلَّمة أفضل. العمل الحقيقي هو في تعريف معنى الفائدة. سؤال pruning criterion انتقل ببساطة مستوى واحدًا إلى أعلى في درجة الحبيبية (granularity)، وقد أعطى الجزء 05 إجابة واحدة بالفعل، وهي معيار L1 أو L2 للصف أو المرشح. والمفهومان التاليان يعطيان إجابتين لا تحتاجان إلى Hessian ولا إلى معيار (norm): انظر إلى التنشيطات التي ينتجها العصبون، أو انظر إلى مدى إمكانية إعادة بناء مخرجات الطبقة دونه.

Recall

A linear layer has weight shape [8, 16]. You prune three output neurons. How many weights disappear and what is the new shape?طبقة خطية شكل أوزانها [8, 16]. قلّمت ثلاثة عصبونات من المخرجات. كم وزنًا يختفي، وما الشكل الجديد؟

Each output neuron owns one row of 16 weights, so 3 × 16 = 48 weights disappear and the matrix becomes [5, 16]. The next layer also loses three input columns.
كل عصبون في المخرجات يملك صفًا واحدًا من 16 وزنًا، فيختفي 3 × 16 = 48 وزنًا وتصبح المصفوفة [5, 16]. وتفقد الطبقة التالية أيضًا ثلاثة أعمدة من المدخلات.

ReLU outputs zero for every negative pre-activation. A channel whose output map is mostly zero, image after image, contributes almost nothing to the layer that follows, whatever its weights look like. Hu, Peng, Tai and Tang turned that observation into a criterion. On VGG-16 they found 631 neurons whose activations were zero more than 90% of the time on ImageNet validation images, and they found that the mean fraction of zeros is far higher in the deeper convolutional layers and the fully connected layers than in the early layers, so most of the redundancy sits at the top of the network.

يُخرج ReLU صفرًا لكل قيمة سالبة قبل التنشيط. القناة التي تكون خريطة مخرجاتها صفرًا في معظمها، صورة بعد صورة، لا تساهم بشيء تقريبًا في الطبقة التي تليها، مهما كان شكل أوزانها. حوّل Hu وPeng وTai وTang هذه الملاحظة إلى معيار. على VGG-16 وجدوا 631 عصبونًا كانت تنشيطاتها صفرًا في أكثر من 90% من الوقت على صور التحقق في ImageNet، ووجدوا أن متوسط نسبة الأصفار أعلى بكثير في طبقات الالتفاف العميقة والطبقات المتصلة بالكامل (fully connected) منه في الطبقات الأولى، فمعظم التكرار الزائد يقع في أعلى الشبكة.

LayerالطبقةMean APoZمتوسط APoZ
CONV1-1CONV1-147.07%47.07%
CONV3-3CONV3-369.93%69.93%
CONV4-3CONV4-387.30%87.30%
CONV5-3CONV5-393.19%93.19%
FC6FC675.26%75.26%
FC7FC774.14%74.14%
Mean APoZ per layer of VGG-16 on ImageNet validation (Hu et al., 2016, Table 1)متوسط APoZ لكل طبقة في VGG-16 على بيانات التحقق في ImageNet (Hu وزملاؤه، 2016، الجدول 1)

The score is the APoZ. For channel c of a layer, run N validation images through the network, look at every position of the H × W output map for every image, and count how often the value is exactly zero. Divide by the number of positions you looked at.

الدرجة هي APoZ. للقناة c من طبقة ما، مرّر N صورة تحقق عبر الشبكة، وانظر إلى كل موضع في خريطة المخرجات ذات الأبعاد H × W لكل صورة، وعُدّ كم مرة تكون القيمة صفرًا تمامًا. ثم اقسم على عدد المواضع التي نظرت إليها.

APoZc=∑k=1N∑j=1Mf ⁣(Oc,j(k)=0)N×M,f(true)=1, f(false)=0\mathrm{APoZ}_c = \frac{\sum_{k=1}^{N}\sum_{j=1}^{M} f\!\left(O_{c,j}(k) = 0\right)}{N \times M}, \qquad f(\text{true}) = 1,\ f(\text{false}) = 0
Average Percentage of Zeros for channel c, with M = H x W positions and N images (Hu et al., 2016, eq. 1)متوسط نسبة الأصفار (APoZ) للقناة c، مع M = H x W موضعًا وN صورة (Hu et al., 2016، المعادلة 1)

The slide writes the same thing as zeros divided by batch times height times width. Its example uses a batch of 2, three channels and 4 × 4 maps, so every channel is judged over 2 × 4 × 4 = 32 positions. Count the bold zeros in each grid and the numbers on the slide come out exactly.

تكتب الشريحة الشيء نفسه على أنه عدد الأصفار مقسومًا على حجم الدفعة (batch) مضروبًا في الارتفاع مضروبًا في العرض. مثالها يستخدم دفعة من 2، وثلاث قنوات، وخرائط 4 × 4، فتُقيَّم كل قناة على 2 × 4 × 4 = 32 موضعًا. عُدّ الأصفار الغامقة في كل شبكة وستخرج أرقام الشريحة بالضبط.

Worked exampleمثال محلول

APoZ for the three channels on the slideAPoZ للقنوات الثلاث في الشريحة

  1. Count zeros per channel in batch 1عُدّ الأصفار في كل قناة في الدفعة 1

    Channel 0: 5. Channel 1: 5. Channel 2: 6.
    القناة 0: 5. القناة 1: 5. القناة 2: 6.
  2. Count zeros per channel in batch 2عُدّ الأصفار في كل قناة في الدفعة 2

    Channel 0: 6. Channel 1: 7. Channel 2: 8.
    القناة 0: 6. القناة 1: 7. القناة 2: 8.
  3. Divide the totals by 2 x 4 x 4 = 32اقسم المجاميع على 2 x 4 x 4 = 32

    Channel 0: 11/32 = 0.344. Channel 1: 12/32 = 0.375. Channel 2: 14/32 = 0.438.
    القناة 0: 11/32 = 0.344. القناة 1: 12/32 = 0.375. القناة 2: 14/32 = 0.438.
  4. Channel 2 is prunedتُقلَّم القناة 2

    Smaller APoZ means a more important channel. Channel 2 is silent most often, so it is the one crossed out on the slide; channels 0 and 1 are kept.
    كلما صغرت APoZ كانت القناة أهم. القناة 2 هي الأكثر صمتًا، لذلك هي المشطوبة في الشريحة؛ وتُبقى القناتان 0 و1.

Zero counts verified against the slide gridsأعداد الأصفار بعد التحقق منها مقابل شبكات الشريحة

Channel 0القناة 0
5 + 6 = 11 zeros, APoZ 11/32 = 34.4%5 + 6 = 11 صفرًا، وAPoZ = 11/32 = 34.4%
Channel 1القناة 1
5 + 7 = 12 zeros, APoZ 12/32 = 37.5%5 + 7 = 12 صفرًا، وAPoZ = 12/32 = 37.5%
Channel 2القناة 2
6 + 8 = 14 zeros, APoZ 14/32 = 43.8%6 + 8 = 14 صفرًا، وAPoZ = 14/32 = 43.8%
Denominatorالمقام
batch 2 × height 4 × width 4 = 32الدفعة 2 × الارتفاع 4 × العرض 4 = 32
The zero positions of batch 1 light up in each channel's map, then the three APoZ bars grow. The tallest bar, channel 2, is crossed out.تضيء مواضع الأصفار في الدفعة 1 على خريطة كل قناة، ثم تنمو أعمدة APoZ الثلاثة. يُشطب العمود الأطول، وهو القناة 2.
SimulatorمحاكيAPoZ trimmer: click activations to zero and watch the ranking moveمقلّم APoZ: انقر التنشيطات لتصفيرها وراقب تغير الترتيب
channel 0
channel 1
channel 2

Each grid is one 4 × 4 output map after ReLU. A zero cell is a position where the pre-activation was negative. Switch batches to edit the other 16 positions of the same channel.كل شبكة هي خريطة مخرجات واحدة بحجم 4 × 4 بعد ReLU. الخلية الصفرية موضع كانت قيمته قبل التفعيل سالبة. بدّل الدفعة لتعديل المواضع الـ 16 الأخرى من القناة نفسها.

Channelzeros b1zeros b2totalAPoZbardecision
Channel 05611/3234.4%
keep
Channel 15712/3237.5%
keep
Channel 26814/3243.8%
prune
Denominatorالمقام32positionsbatch 2 × height 4 × width 4الدفعة 2 × الارتفاع 4 × العرض 4
Pruned channelالقناة المقلّمة2APoZ 43.8%highest APoZ loses; a tie goes to the higher channel indexالقناة صاحبة أعلى APoZ تُحذف؛ وعند التعادل تُحذف القناة ذات الفهرس الأعلى

APoZ_c = (z_c,1 + z_c,2) / (2 × 4 × 4)

Direction is the only thing people get wrong here, so state it in words: importance falls as APoZ rises. The paper's operating rule, the procedure it names Network Trimming, is to trim the neurons whose APoZ is more than one standard deviation above the layer's mean, which under a Gaussian assumption on APoZ values rejects about 16% of the neurons in a trimmed layer on average. Trimming is iterative: prune a few high-APoZ layers, retrain with the surviving weights initialized from the pre-trim network rather than from scratch, and repeat. The authors show that training the trimmed architecture from scratch leaves more zero-activation neurons than initializing from the trimmed weights does, so the initialization matters.

الاتجاه هو الشيء الوحيد الذي يخطئ فيه الناس هنا، فلنقله بالكلمات: الأهمية تنخفض كلما ارتفعت APoZ. قاعدة العمل في الورقة، أي الإجراء الذي تسميه Network Trimming، هي تشذيب العصبونات التي تزيد APoZ لديها بأكثر من انحراف معياري واحد فوق متوسط الطبقة، وهذا تحت افتراض توزيع غاوسي لقيم APoZ يستبعد في المتوسط نحو 16% من العصبونات في الطبقة المشذَّبة. التشذيب تكراري: قلّم بضع طبقات ذات APoZ مرتفعة، ثم أعِد التدريب مع تهيئة الأوزان الباقية من الشبكة قبل التشذيب بدلًا من البدء من الصفر، وكرّر. ويبيّن المؤلفون أن تدريب المعمارية المشذَّبة من الصفر يترك عصبونات ذات تنشيط صفري أكثر مما تتركه التهيئة من الأوزان المشذَّبة، فالتهيئة مهمة.

Network Trimming results (Hu et al., 2016)نتائج Network Trimming (Hu وزملاؤه، 2016)

LeNet on MNISTLeNet على MNIST
20-50-500-10 trimmed to 20-24-252-10, 3.85× fewer parameters, accuracy 99.31% to 99.26%شُذّبت من 20-50-500-10 إلى 20-24-252-10، بمعاملات أقل بمقدار 3.85×، وتغيّرت الدقة من 99.31% إلى 99.26%
VGG-16, trim CONV5-3 and FC6VGG-16، تشذيب CONV5-3 وFC6
Top-5 85.900% before retraining, 90.278% after, above the original 88.444%دقة Top-5 هي 85.900% قبل إعادة التدريب و90.278% بعدها، أعلى من القيمة الأصلية 88.444%
VGG-16, trim CONV4, CONV5, FC6, FC7 at onceVGG-16، تشذيب CONV4 وCONV5 وFC6 وFC7 دفعة واحدة
Top-5 falls to 46.650% before retraining, the reason trimming is done a few layers at a timeتنخفض دقة Top-5 إلى 46.650% قبل إعادة التدريب، ولهذا يُجرى التشذيب على بضع طبقات في كل مرة
Validation setمجموعة التحقق
ImageNet, N = 50,000 images per APoZ measurementImageNet، بعدد N = 50,000 صورة لكل قياس APoZ
CriterionالمعيارReadsما يقرؤهCostالكلفةGranularityدرجة الحبيبيةScoreالدرجة
Magnitude (part 05)المقدار (Magnitude، الجزء 05)Weight values onlyقيم الأوزان فقطNone, read the tensorلا شيء، تُقرأ قيم الموتر مباشرةAnyأي مستوى|w|, Lp norm of a structural set|w|، أو معيار Lp لمجموعة هيكلية
OBDOBDWeights and hᵢᵢ from a second backward passالأوزان وقيم hᵢᵢ من تمرير عكسي ثانٍAbout one gradient computationنحو كلفة حساب ميل واحدWeightالوزن½ hᵢᵢ wᵢ²½ hᵢᵢ wᵢ²
APoZAPoZReLU outputs on a validation setمخرجات ReLU على مجموعة تحققOne forward pass over N imagesتمرير أمامي واحد على N صورةNeuron or channelعصبون أو قناةFraction of zero activationsنسبة التنشيطات الصفرية
Regressionالانحدار (Regression)Sampled layer inputs and outputsعيّنات من مدخلات الطبقة ومخرجاتهاLASSO plus least squares per layerLASSO ثم مربعات صغرى لكل طبقةInput channelقناة مدخلاتReconstruction error of Zخطأ إعادة بناء Z
The criteria of parts 05 and 06 compared by what they readمعايير الجزأين 05 و06 مقارنةً بحسب ما تقرؤه

The comparison shows a split that matters for your project. Magnitude and OBD are read off the weights and their derivatives. APoZ and the regression criterion of the next concept are data-driven: they need a forward pass over real inputs, so they capture what the network does on your data rather than what its parameters look like, at the price of needing that data available at pruning time.

تُظهر المقارنة انقسامًا مهمًا لمشروعك. المقدار وOBD يُقرآن من الأوزان ومشتقاتها. أما APoZ ومعيار الانحدار في المفهوم التالي فقائمان على البيانات: يحتاجان إلى تمرير أمامي على مدخلات حقيقية، فيلتقطان ما تفعله الشبكة على بياناتك لا شكل معاملاتها، مقابل ثمن هو ضرورة توفر تلك البيانات وقت التقليم.

Quick checkاختبار سريع

Over a batch of 2 with 4 x 4 maps, channel 2 has 14 zeros and channel 0 has 11. Which is pruned under APoZ?على دفعة من 2 بخرائط 4 x 4، في القناة 2 أربعة عشر صفرًا وفي القناة 0 أحد عشر صفرًا. أيهما يُقلَّم بحسب APoZ؟

Recall

What is the Network Trimming operating threshold, what fraction of a layer's neurons does it remove on average, and why does retraining start from the pre-trim weights?ما عتبة العمل في Network Trimming، وما نسبة عصبونات الطبقة التي تحذفها في المتوسط، ولماذا تبدأ إعادة التدريب من الأوزان السابقة للتشذيب؟

Trim every neuron whose APoZ is more than one standard deviation above the layer's mean, which under a Gaussian assumption on APoZ values removes about 16% of the neurons in that layer. Retraining is initialized from the trimmed network's surviving weights because training the same architecture from scratch leaves more zero-activation neurons behind and recovers less accuracy.
شذّب كل عصبون تزيد APoZ لديه بأكثر من انحراف معياري واحد فوق متوسط الطبقة، وهذا تحت افتراض توزيع غاوسي لقيم APoZ يحذف نحو 16% من عصبونات تلك الطبقة. وتُهيَّأ إعادة التدريب من الأوزان الباقية للشبكة المشذَّبة لأن تدريب المعمارية نفسها من الصفر يترك خلفه عصبونات ذات تنشيط صفري أكثر ويستعيد دقة أقل.

OBD asked what pruning does to the loss. APoZ looked at what a channel emits. He, Zhang and Sun ask a third question that is easier to answer than the first and more precise than the second: after you remove some input channels of a layer, how well can the survivors reproduce the layer's original output? Take one conv layer and sample b positions from real images (the paper used 5000 images with 10 samples each). Unroll each receptive field into a row of a matrix X of shape b × c_i in the slide's simplified picture. The layer's output at those positions is a matrix multiply.

سأل OBD عمّا يفعله التقليم بالخسارة. ونظر APoZ إلى ما تُصدره القناة. أما He وZhang وSun فيطرحون سؤالًا ثالثًا أسهل في الإجابة من الأول وأدق من الثاني: بعد أن تحذف بعض قنوات المدخلات في طبقة ما، إلى أي حد تستطيع القنوات الباقية إعادة إنتاج المخرجات الأصلية للطبقة؟ خذ طبقة التفاف واحدة واسحب عيّنة من b موضعًا من صور حقيقية (استخدمت الورقة 5000 صورة مع 10 عيّنات من كل منها). افرد كل حقل استقبال (receptive field) في صف من مصفوفة X شكلها b × c_i في الصورة المبسطة التي تعرضها الشريحة. مخرجات الطبقة عند تلك المواضع هي عملية ضرب مصفوفات.

Z=XWT=∑c=0ci−1XcWcTZ = X W^{T} = \sum_{c=0}^{c_i - 1} X_c W_c^{T}
Layer output as a sum of per-input-channel contributionsمخرج الطبقة بوصفه مجموع مساهمات كل قناة إدخال

The second equality is the whole idea. A matrix product can be split by the shared dimension: column c of X times row c of W^T is one b × c_o outer product, and Z is the sum of c_i of them, one per input channel. Removing input channel c means removing exactly one term of that sum. Regression-based pruning attaches a switch β_c to each term and asks which switches can be turned off while keeping the sum close to the original.

المساواة الثانية هي الفكرة كلها. يمكن تقسيم حاصل ضرب المصفوفات على البعد المشترك: العمود c من X مضروبًا في الصف c من W^T هو ضرب خارجي (outer product) واحد بالشكل b × c_o، وZ هي مجموع c_i من هذه الحواصل، واحد لكل قناة مدخلات. حذف قناة المدخلات c يعني حذف حد واحد بالضبط من هذا المجموع. يربط regression-based pruning مفتاحًا β_c بكل حد، ويسأل أي المفاتيح يمكن إطفاؤها مع إبقاء المجموع قريبًا من الأصل.

arg⁡min⁡W, β ∥Z−Z^∥F2=∥Z−∑c=0ci−1βc XcWcT∥F2subject to∥β∥0≤Nc\underset{W,\,\beta}{\arg\min}\ \lVert Z - \hat{Z} \rVert_F^2 = \Bigl\lVert Z - \sum_{c=0}^{c_i - 1} \beta_c\, X_c W_c^{T} \Bigr\rVert_F^2 \quad \text{subject to} \quad \lVert \beta \rVert_0 \le N_c
Regression-based channel pruning objective (He, Zhang and Sun, ICCV 2017)هدف تقليم القنوات القائم على الانحدار (He, Zhang and Sun, ICCV 2017)

Name every symbol. β is the Channel selection coefficient, a vector of length c_i; β_c = 0 prunes input channel c. N_c is the number of channels allowed to survive, so the L0 norm constraint counts nonzero switches, the same kind of constraint as the pruning formulation of part 01. The objective is the Reconstruction error: the Frobenius norm is the square root of the sum of all squared entries, so its square is just the elementwise squared error summed over the whole b × c_o output. Nothing about the network loss, the labels or the layers downstream appears anywhere.

سمِّ كل رمز. β هو channel selection coefficient، وهو متجه طوله c_i؛ وβ_c = 0 تقلّم قناة المدخلات c. وN_c هو عدد القنوات المسموح لها بالبقاء، فقيد L0 norm يعدّ المفاتيح غير الصفرية، وهو من نوع القيد نفسه في صياغة التقليم في الجزء 01. والهدف هو reconstruction error: معيار Frobenius norm هو الجذر التربيعي لمجموع مربعات كل العناصر، فمربعه ببساطة هو مجموع مربعات الأخطاء عنصرًا بعنصر على كامل المخرجات b × c_o. لا يظهر في أي مكان شيء عن خسارة الشبكة، ولا عن التسميات (labels)، ولا عن الطبقات اللاحقة.

Setting one beta to zero removes a column of X and the matching row of W^T together. Z keeps its b by c_o shape and is rebuilt as Z hat from the surviving channels.جعل قيمة beta واحدة صفرًا يحذف عمودًا من X والصف المقابل له من W^T معًا. تحتفظ Z بشكلها b في c_o، ويُعاد بناؤها على صورة Z hat من القنوات الباقية.

The figure on the slide shows why the input side is the one that shrinks. X_P loses a column and W_P^T loses the row that multiplied it; the two disappear as a pair, because they were only ever used together. The output Ẑ still has b rows and c_o columns. The next layer sees an input of the same shape as before, only slightly perturbed, which is what lets the paper prune a very deep network layer by layer and account for the accumulated error by always regressing toward the un-pruned model's output.

يوضح الشكل في الشريحة لماذا يكون جانب المدخلات هو الذي يصغر. تفقد X_P عمودًا وتفقد W_P^T الصف الذي كان يُضرب فيه؛ يختفيان معًا كزوج، لأنهما لم يُستخدما إلا معًا. أما المخرجات Ẑ فما زال فيها b صفًا وc_o عمودًا. الطبقة التالية ترى مدخلات بالشكل نفسه كما كانت، مع اضطراب طفيف فقط، وهذا ما يسمح للورقة بتقليم شبكة عميقة جدًا طبقة بعد طبقة ومراعاة الخطأ المتراكم بأن تجعل الانحدار دائمًا نحو مخرجات النموذج غير المقلَّم.

Solving it: alternate between selecting and rebuildingالحل: التناوب بين الاختيار وإعادة البناء

The L0 constraint makes the problem NP-hard, so the paper relaxes it to an L1 penalty, adding λ ||β||₁ to the objective. That turns channel selection into LASSO regression, whose solutions are naturally sparse: as λ grows, more β_c are driven exactly to zero. With two unknowns, β and W, the paper alternates.

قيد L0 يجعل المسألة NP-hard، لذلك تُرخيها الورقة إلى عقوبة L1، بإضافة λ ||β||₁ إلى الهدف. هذا يحوّل اختيار القنوات إلى انحدار LASSO، وحلوله متفرقة (sparse) بطبيعتها: كلما كبرت λ دُفعت قيم β_c أكثر إلى الصفر تمامًا. ومع وجود مجهولين، β وW، تتناوب الورقة بينهما.

StepالخطوةFixedالمثبَّتSolvedالمجهول المحلولSolverطريقة الحلOutputالناتج
11WWββLASSO (L1-relaxed selection)LASSO (اختيار مُرخى بعقوبة L1)Which input channels surviveأي قنوات المدخلات تبقى
22ββWWLeast squares (closed form)المربعات الصغرى (صيغة مغلقة)Weights that best rebuild Z from the survivorsالأوزان التي تعيد بناء Z بأفضل شكل من القنوات الباقية
The two alternating stepsالخطوتان المتناوبتان

With W fixed, Ẑ is linear in β, so the objective is an ordinary least-squares fit in β and the added L1 penalty makes it a LASSO problem that picks the channels. With β fixed, the survivors' weights are re-fitted by ordinary least squares so that they rebuild Z as well as possible, in closed form. A constraint ||W_c||_F = 1 on each channel's weights stops the trivial solution of shrinking β while inflating W. In practice the authors run the selection step repeatedly, raising λ until ||β||₀ drops to the target, and then run the reconstruction step once.

عند تثبيت W تكون Ẑ خطية في β، فيصبح الهدف ملاءمة عادية بالمربعات الصغرى في β، وعقوبة L1 المضافة تجعلها مسألة LASSO تختار القنوات. وعند تثبيت β يُعاد ملاءمة أوزان القنوات الباقية بالمربعات الصغرى العادية لتعيد بناء Z بأفضل ما يمكن، بصيغة مغلقة (closed form). ويمنع القيد ||W_c||_F = 1 على أوزان كل قناة الحل التافه الذي يصغّر β بينما يضخّم W. وفي التطبيق يشغّل المؤلفون خطوة الاختيار مرارًا، رافعين λ حتى تنخفض ||β||₀ إلى القيمة المستهدفة، ثم يشغّلون خطوة إعادة البناء مرة واحدة.

Channel pruning results (He, Zhang and Sun, ICCV 2017)نتائج تقليم القنوات (He وZhang وSun، ICCV 2017)

VGG-16
4× speedup with 1.0% increase in top-5 error; 5× with tensor factorization at 0.3%تسريع 4× مع زيادة 1.0% في خطأ top-5؛ و5× مع تحليل الموترات (tensor factorization) بزيادة 0.3%
ResNet-50 and Xception-50ResNet-50 وXception-50
2× speedup at 1.4% and 1.0% extra top-5 errorتسريع 2× مقابل زيادة 1.4% و1.0% في خطأ top-5
Fine-tuningالضبط الدقيق (Fine-tuning)
10 epochs, batch 128, learning rate 10⁻⁵10 حقب (epochs)، ودفعة بحجم 128، ومعدل تعلّم 10⁻⁵
Samples for regressionعيّنات الانحدار
5000 images × 10 positions each5000 صورة × 10 مواضع من كل صورة

Quick checkاختبار سريع

In regression-based channel pruning, what does setting beta_c = 0 do?في التقليم القائم على الانحدار لاختيار القنوات، ماذا يفعل جعل beta_c = 0؟

Recall

State the regression-based pruning objective and its two alternating steps.اكتب هدف التقليم القائم على الانحدار وخطوتيه المتناوبتين.

Minimize over W and β the value ||Z - Σ_c β_c X_c W_c^T||_F² subject to ||β||₀ ≤ N_c. Step one fixes W and solves for β by LASSO, which selects channels. Step two fixes β and solves for W by least squares, which rebuilds the output.
قلّل على W وβ القيمة ||Z - Σ_c β_c X_c W_c^T||_F² بشرط ||β||₀ ≤ N_c. الخطوة الأولى تثبّت W وتحل لإيجاد β بـ LASSO، وهذا يختار القنوات. الخطوة الثانية تثبّت β وتحل لإيجاد W بالمربعات الصغرى، وهذا يعيد بناء المخرجات.

The reference list at the end of the deck is a map of where every Pruning criterion in parts 05 and 06 came from, and of what comes next. Reading it as a family tree makes the lecture easier to hold in memory than reading it as nineteen unrelated titles.

قائمة المراجع في نهاية العرض خريطة لمصدر كل pruning criterion في الجزأين 05 و06، ولما يأتي بعدها. قراءتها كشجرة عائلة تجعل المحاضرة أسهل في التذكر من قراءتها كتسعة عشر عنوانًا لا رابط بينها.

CriterionالمعيارWhat it readsما يقرؤهRefالمرجعPaperالورقةWhere taughtأين يُدرَّس
Magnitudeالمقدار (Magnitude)Weight valuesقيم الأوزان44Han et al., NeurIPS 2015Han et al., NeurIPS 2015Part 05الجزء 05
Scaling factorمعامل التحجيم (Scaling factor)Trainable γ per channelمعامل γ قابل للتدريب لكل قناة1111Liu et al., Network Slimming, ICCV 2017Liu et al., Network Slimming, ICCV 2017Part 05الجزء 05
Second orderالدرجة الثانية (Second order)Loss curvature hᵢᵢانحناء الخسارة hᵢᵢ33LeCun, Denker, Solla, NeurIPS 1989LeCun, Denker, Solla, NeurIPS 1989This partهذا الجزء
Second order, modernالدرجة الثانية، الحديثHessian of a layer-wise reconstructionHessian لمسألة إعادة بناء على مستوى الطبقة1818Frantar and Alistarh, SparseGPT, 2023Frantar and Alistarh, SparseGPT, 2023Pointerإشارة فقط
Activationالتنشيط (Activation)Zero fraction after ReLUنسبة الأصفار بعد ReLU1414Hu et al., Network Trimming, 2016Hu et al., Network Trimming, 2016This partهذا الجزء
Regressionالانحدار (Regression)Layer output reconstructionإعادة بناء مخرجات الطبقة1616He, Zhang, Sun, ICCV 2017He, Zhang, Sun, ICCV 2017This partهذا الجزء
Next-layer statisticsإحصاءات الطبقة التاليةNext layer's reconstructionإعادة بناء الطبقة التالية1717Luo, Wu, Lin, ThiNet, ICCV 2017Luo, Wu, Lin, ThiNet, ICCV 2017Pointerإشارة فقط
First-order Taylorتايلور من الدرجة الأولىGradient times value on mini-batchesالميل مضروبًا في القيمة على دفعات صغيرة15, 1315, 13Molchanov et al., ICLR 2017 and CVPR 2019Molchanov et al., ICLR 2017 and CVPR 2019Pointerإشارة فقط
Criteria mapped onto the reference list of slide 43المعايير موزعة على قائمة المراجع في الشريحة 43

Three of the pointers deserve a sentence each. SparseGPT is the modern descendant of Second-order pruning: it prunes GPT-scale models with 175 billion parameters in one shot to 50 to 60% unstructured sparsity with little loss in perplexity, using Hessian information of a layer-wise reconstruction problem very much like the one in the previous concept. ThiNet selects filters using statistics from the next layer rather than the current one, a cousin of Regression-based pruning. Molchanov's first-order Taylor criterion scores units by gradient times value on mini-batches. It is the same expansion as OBD with the gradient term kept and the Hessian dropped.

ثلاث من هذه الإشارات تستحق جملة لكل منها. SparseGPT هو السليل الحديث لـ second-order pruning: يقلّم نماذج بحجم GPT فيها 175 مليار معامل دفعة واحدة إلى تفرّق غير هيكلي (unstructured sparsity) بنسبة 50 إلى 60% مع خسارة قليلة في الـ perplexity، مستخدمًا معلومات الـ Hessian لمسألة إعادة بناء على مستوى الطبقة تشبه كثيرًا تلك التي في المفهوم السابق. ThiNet يختار المرشحات باستخدام إحصاءات من الطبقة التالية بدلًا من الطبقة الحالية، وهو قريب من regression-based pruning. ومعيار تايلور من الدرجة الأولى عند Molchanov يقيّم الوحدات بحاصل ضرب الميل في القيمة على دفعات صغيرة. إنه المفكوك نفسه في OBD مع الإبقاء على حد الميل وإسقاط الـ Hessian.

Recall

Given the criterion, name the paper and what it reads: magnitude, OBD, APoZ, regression.لكل معيار، سمِّ الورقة وما يقرؤه: magnitude وOBD وAPoZ وregression.

Magnitude: Han et al. 2015, weight values. OBD: LeCun, Denker and Solla 1989, the diagonal of the Hessian times the squared weight. APoZ: Hu et al. 2016, the fraction of zero ReLU activations on validation data. Regression: He, Zhang and Sun 2017, the reconstruction error of the layer output.
Magnitude: Han وزملاؤه 2015، قيم الأوزان. OBD: LeCun وDenker وSolla 1989، قطر الـ Hessian مضروبًا في مربع الوزن. APoZ: Hu وزملاؤه 2016، نسبة تنشيطات ReLU الصفرية على بيانات التحقق. Regression: He وZhang وSun 2017، خطأ إعادة بناء مخرجات الطبقة.

Recall

Which of the criteria in this part need data pushed through the network, and which read only the parameters?أي معايير هذا الجزء يحتاج إلى تمرير بيانات عبر الشبكة، وأيها يقرأ المعاملات فقط؟

APoZ needs activations from a forward pass and regression needs sampled layer inputs and outputs, so both are data-driven. Magnitude reads only the weights. OBD reads the weights and h_ii; computing that diagonal does use training data through a second backward pass, but no activations are stored or scored.
APoZ يحتاج إلى تنشيطات من تمرير أمامي، والانحدار يحتاج إلى عيّنات من مدخلات الطبقة ومخرجاتها، فكلاهما قائم على البيانات. المقدار يقرأ الأوزان فقط. OBD يقرأ الأوزان وh_ii؛ وحساب ذلك القطر يستخدم بيانات التدريب فعلًا عبر تمرير عكسي ثانٍ، لكن لا تُخزَّن أي تنشيطات ولا تُقيَّم.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • Pruning is a perturbation delta W. Its loss cost is approximated by a second-order Taylor expansion with a gradient term, a diagonal Hessian term, cross terms and a cubic remainder.التقليم اضطراب delta W في الأوزان. تُقرَّب كلفته على الخسارة بمفكوك تايلور من الدرجة الثانية يضم حد الميل (gradient)، وحد قطر الـ Hessian، والحدود التقاطعية، وباقيًا من الدرجة الثالثة.
  • OBD keeps only 1/2 h_ii w_i^2: the quadratic assumption removes the remainder, convergence removes the gradient term, independent deletions remove the cross terms; h_ii is non-negative at a minimum.يُبقي OBD الحد 1/2 h_ii w_i^2 وحده: افتراض الشكل التربيعي يحذف الباقي، والتقارب يحذف حد الميل، واستقلال عمليات الحذف يحذف الحدود التقاطعية؛ وتكون h_ii غير سالبة عند القيمة الصغرى.
  • Magnitude pruning is OBD with every h_ii equal. The full Hessian has n^2 entries; OBD computes only the diagonal by a second back-propagation pass.التقليم بالمقدار هو OBD حين تتساوى كل قيم h_ii. يضم الـ Hessian الكامل n^2 عنصرًا، أما OBD فيحسب القطر فقط بتمرير ثانٍ للانتشار العكسي (back-propagation).
  • Removing a neuron deletes a row of a linear weight matrix; removing a conv channel deletes a whole filter. Neuron pruning is coarse-grained weight pruning.حذف عصبون يحذف صفًا من مصفوفة أوزان الطبقة الخطية، وحذف قناة في طبقة الالتفاف يحذف مرشحًا (filter) كاملًا. تقليم العصبونات هو تقليم أوزان خشن الحبيبات (coarse-grained).
  • APoZ = zeros / (batch x H x W). The slide's channels score 11/32, 12/32 and 14/32 and the largest, channel 2, is pruned. Smaller APoZ means more important.APoZ = عدد الأصفار / (batch x H x W). قنوات الشريحة تحصل على 11/32 و12/32 و14/32، وتُقلَّم القناة 2 صاحبة القيمة الأكبر. كلما صغرت APoZ زادت أهمية القناة.
  • Regression-based pruning minimizes ||Z - sum_c beta_c X_c W_c^T||_F^2 subject to ||beta||_0 <= N_c, alternating LASSO channel selection and least-squares reconstruction. VGG-16 reached 4x speedup at 1.0 percent extra top-5 error.التقليم القائم على الانحدار يقلّل ||Z - sum_c beta_c X_c W_c^T||_F^2 بشرط ||beta||_0 <= N_c، بالتناوب بين اختيار القنوات بـ LASSO وإعادة البناء بالمربعات الصغرى. وصل VGG-16 إلى تسريع 4x مقابل زيادة 1.0 بالمئة في خطأ top-5.
  • Slide errata: the h_ii denominator on slide 36, the sign convention on slide 34, Network Trimming is 2016 not 2017, and the 'more importance' typo on slide 40.أخطاء الشرائح: مقام h_ii في الشريحة 36، واصطلاح الإشارة في الشريحة 34، وأن Network Trimming صدرت عام 2016 لا 2017، والخطأ اللغوي 'more importance' في الشريحة 40.

Sourcesالمصادر