Majid Al-RaimiFine-tuning, iterative pruning and regularizationالضبط الدقيق والتقليم التكراري والتنظيم

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

Fine-tuning, iterative pruning and regularizationالضبط الدقيق والتقليم التكراري والتنظيم

Pruning costs accuracy, fine-tuning at a much smaller learning rate recovers it, repeating prune and fine-tune pushes AlexNet from 5x to 9x compression, and L1 or L2 regularization during training makes weights easier to prune.التقليم يكلّف دقة، والضبط الدقيق بمعدل تعلم أصغر بكثير يستعيدها، وتكرار التقليم والضبط الدقيق يرفع ضغط AlexNet من 5x إلى 9x، والتنظيم L1 أو L2 أثناء التدريب يجعل الأوزان أسهل تقليمًا.

Conceptsالمفاهيم
4
Slidesالشرائح
41-52
Readingمدة القراءة
24 min24 دقيقة
Understoodما فهمته
0/4 conceptsمفاهيم

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

Every pruning method in this course, magnitude pruning, AMC, NetAdapt and the 2:4 sparsity of part 10, only reaches its quoted ratio because a fine-tuning step follows the cut. The EIE numbers in the next part assume the roughly 89% weight sparsity that this part explains how to obtain.

This is the fifth of the five questions the lecture opened with, and for embedded research it is the recipe you will actually run: cut, retrain the survivors gently, cut again. Two hyperparameters decide whether the loop works, the learning rate during fine-tuning and the regularizer used during training, and both are favorite exam questions because each has a single number or a single formula attached.

كل طريقة تقليم في هذا المقرر، الـ magnitude pruning والـ AMC والـ NetAdapt والـ2:4 sparsity في الجزء 10، لا تصل إلى النسبة المذكورة لها إلا لأن خطوة fine-tuningتأتي بعد القطع. وأرقام EIE في الجزء التالي تفترض weight sparsity تقارب 89%، وهذا الجزء يشرح كيف نحصل عليها.

هذا هو السؤال الخامس من الأسئلة الخمسة التي افتُتحت بها المحاضرة، وفي بحوث الأنظمة المدمجة هو الوصفة التي ستنفّذها فعلًا: اقطع، ثم أعِد تدريب الأوزان الباقية بلطف، ثم اقطع مرة أخرى. هناك معاملان فائقان (hyperparameters) يحددان هل تنجح الحلقة أم لا: معدل التعلّم أثناء الـ fine-tuning، والـregularizer المستخدم أثناء التدريب. وكلاهما من أسئلة الامتحان المفضّلة لأن لكل منهما رقمًا واحدًا أو معادلة واحدة مرتبطة به.

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

  1. Explain why accuracy drops after pruning and why fine-tuning at 1/10 to 1/100 of the original learning rate recovers it.أن تشرح لماذا تنخفض الدقة بعد التقليم (pruning)، ولماذا يستعيدها الـ fine-tuning بمعدل تعلّم يساوي 1/10 إلى 1/100 من معدل التعلّم الأصلي.
  2. Draw the Train Connectivity, Prune Connections, Train Weights pipeline with its loop arrow, and define one iteration.أن ترسم خط المعالجة Train Connectivity ثم Prune Connections ثم Train Weights مع سهم الحلقة، وأن تعرّف التكرار الواحد (iteration).
  3. Read the three accuracy-loss curves and quote the 5x to 9x AlexNet result with its parameter counts.أن تقرأ منحنيات فقدان الدقة الثلاثة، وأن تذكر نتيجة AlexNet من 5x إلى 9x مع أعداد المعاملات.
  4. Write the L1 and L2 regularized losses, say which yields exact zeros, and explain why L2 still won for magnitude pruning.أن تكتب دالتَي الخسارة مع الـ L1 والـ L2 regularization، وأن تقول أيّهما يعطي أصفارًا تامة، وأن تشرح لماذا فاز الـ L2 مع ذلك في الـ magnitude pruning.
  5. Connect Network Slimming's penalty on batch norm scaling factors to scaling-based channel pruning from lecture 04-1.أن تربط عقوبة Network Slimming على معاملات التحجيم (scaling factors) في الـ batch norm بتقليم القنوات المبني على التحجيم من المحاضرة 04-1.

Take the AlexNet that Han, Pool, Tran and Dally started from in 2015: 61 million parameters, five convolution layers and three fully connected ones, 57.2% top-1 accuracy. They kept roughly one weight in nine and ended with a network that was not measurably worse. That is the headline of this part, and the whole trick behind it is what happens after the cut.

خذ شبكة AlexNet التي بدأ منها Han وPool وTran وDally عام 2015: 61 million معامل، وخمس طبقات convolution وثلاث طبقات fully connected، ودقة top-1 قدرها 57.2%. أبقوا تقريبًا وزنًا واحدًا من كل تسعة، وانتهوا بشبكة ليست أسوأ بشكل يمكن قياسه. هذا هو العنوان الرئيسي لهذا الجزء، والحيلة كلها وراءه هي ما يحدث بعد القطع.

AlexNet before and after prune plus retrain (Han et al. 2015, Table 1 and section 4.2)AlexNet قبل التقليم مع إعادة التدريب وبعده (Han et al. 2015، الجدول 1 والقسم 4.2)

Parametersعدد المعاملات
61M to 6.7M (9x)من 61M إلى 6.7M (9x)
Top-1 errorخطأ top-1
42.78% to 42.77%من 42.78% إلى 42.77%
Top-5 errorخطأ top-5
19.73% to 19.67%من 19.73% إلى 19.67%
Original training timeزمن التدريب الأصلي
75 hours on a Titan X75 ساعة على Titan X
Retraining time after pruningزمن إعادة التدريب بعد التقليم
173 hours at 1/100 of the initial learning rate173 ساعة بمعدل تعلّم يساوي 1/100 من معدل التعلّم الابتدائي

Now look at what those hours say. Retraining took more than twice as long as training. The authors did not treat it as optional polish; section 3 of the paper calls the final retraining step critical and states that if the pruned network is used without retraining, accuracy is significantly impacted. So the answer to the outline's fifth question, how to fine-tune a pruned network, is a method, not a footnote: the Pruning mask decides which weights exist, and Fine-tuning decides whether the survivors can still do the job.

انظر الآن إلى ما تقوله تلك الساعات. استغرقت إعادة التدريب أكثر من ضعف مدة التدريب. لم يعامل المؤلفون هذه الخطوة كتلميع اختياري؛ فالقسم 3 من الورقة يصف خطوة إعادة التدريب الأخيرة بأنها حاسمة، ويقرر أنه إذا استُخدمت الشبكة المقلَّمة دون إعادة تدريب فإن الدقة تتأثر بشكل كبير. لذلك فإن جواب السؤال الخامس في المخطط، أي كيف نعمل fine-tune لشبكة مقلَّمة، هو طريقة قائمة بذاتها لا حاشية: الـ mask الخاص بالـ pruning يقرر أي الأوزان موجودة، والـ fine-tuning يقرر هل تستطيع الأوزان الباقية أن تؤدي المهمة.

Why the survivors are wounded, and why the wound healsلماذا تتضرر الأوزان الباقية، ولماذا يلتئم الجرح

A trained layer is a set of weights that were optimized together. Zeroing the smallest of them, the magnitude criterion from lecture 04-1, is a small perturbation to any one output, but a large Pruning ratio removes so many small contributions that the outputs shift and the accuracy drops, more steeply the higher the ratio (this is what the chart on the slide shows for the dashed curve). The survivors are still near a good solution, though. Nothing about them was wrong; the function they were tuned to complete simply lost some of its terms. Fine-tuning continues gradient descent on exactly those survivors, with the removed weights held at zero, so they can absorb the work of the missing ones.

الطبقة المدرَّبة هي مجموعة أوزان جرى تحسينها معًا. تصفير أصغرها، أي magnitude criterion من المحاضرة 04-1، هو اضطراب صغير لأي مخرج منفرد، لكن pruning ratio كبيرة تزيل مساهمات صغيرة كثيرة جدًا، فتنزاح المخرجات وتنخفض الدقة، ويكون الانخفاض أشد كلما ارتفعت النسبة (وهذا ما يُظهره الرسم في الشريحة للمنحنى المتقطع). ومع ذلك تبقى الأوزان الباقية قريبة من حل جيد. لم يكن فيها أي خطأ؛ كل ما في الأمر أن الدالة التي ضُبطت لتكملها فقدت بعض حدودها. الـ fine-tuning يواصل الـ gradient descent على تلك الأوزان الباقية تحديدًا، مع إبقاء الأوزان المحذوفة عند الصفر، فتستطيع أن تتحمّل عمل الأوزان المفقودة.

This is why the learning rate matters so much. The slide states the rule: the fine-tuning learning rate is usually 1/100 or 1/10 of the original learning rate. In the paper, LeNet was retrained at 1/10 of the original rate (section 4.1) and AlexNet at 1/100 of the initial rate (section 4.2). A large step would throw the weights out of the basin in which the magnitude ranking was measured, undoing the very judgement the pruning made. Small steps walk the network back down the loss surface from where the cut left it.

ولهذا يهمّ معدل التعلّم كثيرًا. تذكر الشريحة القاعدة: معدل التعلّم في الـ fine-tuning يكون عادةً 1/100 أو 1/10 من معدل التعلّم الأصلي. في الورقة، أُعيد تدريب LeNet بمعدل 1/10 من المعدل الأصلي (القسم 4.1)، وأُعيد تدريب AlexNet بمعدل 1/100 من المعدل الابتدائي (القسم 4.2). الخطوة الكبيرة سترمي الأوزان خارج الحوض (basin) الذي قيس فيه ترتيب المقادير، فتُلغي الحكم نفسه الذي بنى عليه التقليم قراره. أما الخطوات الصغيرة فتعيد الشبكة نزولًا على سطح الخسارة من المكان الذي تركها فيه القطع.

Slide 41 makes the same point as an optimization statement. Pruning poses the problem as minimizing the loss over the pruned weights W_P subject to a budget N on the L0 norm, the count of nonzero weights. The mask chooses which entries of W_P may be nonzero at all (the constraint), and fine-tuning is the argmin over the survivors with that mask fixed: the best values the kept weights can take.

الشريحة 41 تقول الفكرة نفسها في صيغة مسألة تحسين. التقليم يصوغ المسألة على أنها تقليل الخسارة على الأوزان المقلَّمة W_P بشرط ميزانية N على الـ L0 norm، أي عدد الأوزان غير الصفرية. الـ mask يختار أي عناصر W_P يُسمح لها أصلًا بأن تكون غير صفرية (القيد)، والـ fine-tuning هو الـ argmin على الأوزان الباقية مع تثبيت ذلك الـ mask: أفضل قيم يمكن أن تأخذها الأوزان المحتفَظ بها.

arg⁡min⁡WPL(x;WP) s.t. ∥WP∥0≤N\arg\min_{\mathbf{W}_P} L(\mathbf{x};\mathbf{W}_P)\ \text{s.t.}\ \|\mathbf{W}_P\|_0 \le N
Slide 41: pruning as constrained optimization; fine-tuning solves the argmin over the survivorsالشريحة 41: التقليم بوصفه تحسينًا مقيدًا؛ والضبط الدقيق (fine-tuning) يحل argmin على الأوزان الباقية
Pruning kicks the network partway up the loss bowl. Fine-tuning at a tenth or a hundredth of the original rate takes many small steps back to the minimum; one original-sized step overshoots to the far wall.التقليم يدفع الشبكة جزءًا من الطريق صعودًا على جدار وعاء الخسارة. الـ fine-tuning بعُشر المعدل الأصلي أو بجزء من مئة منه يأخذ خطوات صغيرة كثيرة عائدًا إلى القاع؛ أما خطوة واحدة بحجم المعدل الأصلي فتتجاوز القاع إلى الجدار المقابل.

The paper adds a second reason to keep the survivors instead of re-initializing them. Section 3.3 observes that networks contain fragile co-adapted features: gradient descent finds a good solution when the network is first trained, but not after re-initializing some layers and retraining them. Fine-tuning starts from the co-adapted weights and preserves that structure. The paper also notes that during retraining it can help to fix the convolution parameters while the fully connected ones retrain, and vice versa, to avoid vanishing gradients through the sparse layers.

تضيف الورقة سببًا ثانيًا للاحتفاظ بالأوزان الباقية بدل إعادة تهيئتها. يلاحظ القسم 3.3 أن الشبكات تحتوي على سمات هشّة متكيّفة معًا (co-adapted features): الـ gradient descent يجد حلًا جيدًا عند تدريب الشبكة أول مرة، لكنه لا يجده بعد إعادة تهيئة بعض الطبقات وإعادة تدريبها. الـ fine-tuning يبدأ من الأوزان المتكيّفة معًا ويحافظ على تلك البنية. وتذكر الورقة أيضًا أنه قد يفيد أثناء إعادة التدريب تثبيت معاملات الـ convolution بينما يُعاد تدريب طبقات الـ fully connected، والعكس، لتجنّب تلاشي المشتقات (vanishing gradients) عبر الطبقات المتفرّقة.

The three-box pipelineخط المعالجة ذو الصناديق الثلاثة

The figure on the slide is Figure 2 of the paper. The first box, Train Connectivity, is ordinary training, but its purpose is reframed: it learns which connections are important, not their final values. The second box, Prune Connections, applies the magnitude threshold. The third box, Train Weights, retrains the sparse network. In Han et al.'s implementation the threshold was a quality parameter multiplied by the standard deviation of each layer's weights, and Caffe was modified to add a mask that disregards pruned parameters during network operation for each weight tensor.

الشكل في الشريحة هو Figure 2 من الورقة. الصندوق الأول، Train Connectivity، تدريب عادي، لكن غرضه أُعيدت صياغته: هو يتعلّم أي الاتصالات مهمة، لا قيمها النهائية. الصندوق الثاني، Prune Connections، يطبّق عتبة المقدار. والصندوق الثالث، Train Weights، يعيد تدريب الشبكة المتفرّقة. في تطبيق Han et al. كانت العتبة معامل جودة مضروبًا في الانحراف المعياري لأوزان كل طبقة، وعُدّل Caffe بإضافة mask لكل tensor أوزان يتجاهل المعاملات المقلَّمة أثناء تشغيل الشبكة.

Train ConnectivityTrain Connectivity
dense trainingتدريب كثيف

Learn which connections matter, not just their values.

تعلّم أي الوصلات مهمة، لا قيمها فقط.

rank by |w|رتّب حسب |w|
Prune ConnectionsPrune Connections
threshold on magnitudeحدّ على المقدار

Zero weights below the threshold and fix the mask.

صفّر الأوزان التي تحت الحد وثبّت القناع.

LR / 10 to LR / 100
Train WeightsTrain Weights
fine-tune survivorsضبط دقيق للأوزان الباقية

Retrain the sparse network to recover accuracy.

أعد تدريب الشبكة المتناثرة لاستعادة الدقة.

Train Connectivity, Prune Connections, Train Weights (Han et al. 2015, Figure 2)Train Connectivity ثم Prune Connections ثم Train Weights (Han et al. 2015، الشكل 2)

Reading the chart on slide 43قراءة الرسم في الشريحة 43

The chart plots accuracy loss against the fraction of parameters pruned away for AlexNet. The dashed purple curve is pruning with no retraining; the green curve adds fine-tuning. Reading the points off the figure gives the following.

يرسم المخطط فقدان الدقة مقابل نسبة المعاملات المقلَّمة في AlexNet. المنحنى البنفسجي المتقطع هو التقليم دون إعادة تدريب؛ والمنحنى الأخضر يضيف الـ fine-tuning. قراءة النقاط من الشكل تعطي ما يلي.

Pruned awayالنسبة المقلَّمةPruning onlyالتقليم فقطPruning + fine-tuningالتقليم مع fine-tuning
50%50%about -0.1نحو -0.1about 0.0نحو 0.0
67%67%about -0.9نحو -0.9about +0.2نحو +0.2
75%75%about -2.1نحو -2.1about +0.2نحو +0.2
80%80%about -4.0نحو -4.0about 0.0نحو 0.0
85.5%85.5%off the chartخارج الرسمabout -0.5نحو -0.5
90%90%off the chartخارج الرسمabout -1.7نحو -1.7
93%93%off the chartخارج الرسمabout -3.8نحو -3.8
Accuracy loss read off the slide 43 chartفقدان الدقة كما يُقرأ من رسم الشريحة 43

The paper summarizes the same curves in section 5: without retraining, accuracy begins dropping much sooner, at one third of the original connections rather than one tenth. It describes a free lunch of removing half the connections with no loss even without retraining, while with retraining the connections can be reduced by 9x. Read that 9x carefully: it is reached with the iterative scheme of the next two concepts. A single prune and retrain, the green curve, is already at about -1.7% by 90% pruned. Two green points (at about 67% and 75% pruned) sit slightly above zero, which the authors attribute to pruning finding the right capacity of the network and thereby reducing overfitting. Because sparsity and compression ratio are two ways of saying the same thing, keep the conversion at hand: ratio = 1 / (1 - s).

تلخّص الورقة المنحنيات نفسها في القسم 5: دون إعادة تدريب تبدأ الدقة بالانخفاض أبكر بكثير، عند بقاء ثلث الاتصالات الأصلية بدل العُشر. وتصف "وجبة مجانية" (free lunch) هي إزالة نصف الاتصالات دون أي فقدان حتى بلا إعادة تدريب، بينما مع إعادة التدريب يمكن تقليل الاتصالات بمقدار 9x. اقرأ هذا الـ 9x بعناية: فهو يتحقق بالمخطط التكراري في المفهومين التاليين. أما تقليم واحد مع إعادة تدريب واحدة، أي المنحنى الأخضر، فيكون عند نحو -1.7% بالفعل عند 90% مقلَّمة. وتقع نقطتان خضراوان (عند نحو 67% و75% مقلَّمة) فوق الصفر بقليل، ويعزو المؤلفون ذلك إلى أن التقليم يجد السعة المناسبة للشبكة فيقلّل الـ overfitting. ولأن الـ sparsity ونسبة الضغط طريقتان لقول الشيء نفسه، أبقِ التحويل في متناول يدك: النسبة = 1 / (1 - s).

RatioالنسبةPruned awayالنسبة المقلَّمة
2x2x50%50%
3x3x66.7%66.7%
5x5x80%80%
9x9x88.9%88.9%
10x10x90%90%
13x13x92.3%92.3%
Compression ratio to fraction pruned away, s = 1 - 1/ratioمن نسبة الضغط إلى النسبة المقلَّمة، s = 1 - 1/ratio

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

Fine-tuning a pruned network usually uses which learning rate, relative to the original?ما معدل التعلّم المستخدم عادةً في الـ fine-tuning لشبكة مقلَّمة، مقارنةً بالمعدل الأصلي؟

Recall

What learning rate does fine-tuning a pruned network usually use, and why?ما معدل التعلّم المستخدم عادةً في الـ fine-tuning لشبكة مقلَّمة، ولماذا؟

1/10 to 1/100 of the original (Han et al.: 1/10 for LeNet, 1/100 for AlexNet). The survivors are already near a good minimum; large steps would leave the basin and destroy the co-adapted features the pruning ranked.
من 1/10 إلى 1/100 من المعدل الأصلي (عند Han et al.: 1/10 لـ LeNet، و1/100 لـ AlexNet). الأوزان الباقية قريبة أصلًا من قاع جيد؛ والخطوات الكبيرة ستخرجها من الحوض وتدمّر السمات المتكيّفة معًا التي رتّبها التقليم.

Once retraining is part of the recipe, a natural question follows: why cut to the final sparsity in one go? The slides tell the story as a sequence. Prune to 30%, retrain the weights. Prune to 50%, retrain. Prune to 70%, retrain. The only change to the pipeline figure is a single arrow from Train Weights back up to Prune Connections, and that arrow is the whole idea of Iterative pruning.

ما دامت إعادة التدريب جزءًا من الوصفة، فإن سؤالًا طبيعيًا يتبع: لماذا نقطع إلى الـ sparsity النهائية دفعة واحدة؟ الشرائح تروي القصة كسلسلة. قلّم إلى 30%، وأعِد تدريب الأوزان. قلّم إلى 50%، وأعِد التدريب. قلّم إلى 70%، وأعِد التدريب. التغيير الوحيد في شكل خط المعالجة هو سهم واحد من Train Weights عائدًا إلى Prune Connections، وهذا السهم هو الفكرة كلها في الـ iterative pruning.

Define the unit first: one iteration is a prune followed by a fine-tune. Iterative pruning repeats that unit while gradually increasing the target sparsity in each iteration, instead of jumping to the final sparsity in one step. Han et al. put it plainly in section 3.4: learning the right connections is an iterative process, pruning followed by retraining is one iteration, and after many such iterations the minimum number of connections can be found. Each iteration is a greedy search for the best connections. They also tried pruning parameters probabilistically by absolute value and found it gave worse results.

عرّف الوحدة أولًا: التكرار الواحد هو prune يتبعه fine-tune. الـ iterative pruning يكرر هذه الوحدة مع رفع الـ sparsity المستهدفة تدريجيًا في كل تكرار، بدل القفز إلى الـ sparsity النهائية في خطوة واحدة. يقولها Han et al. بوضوح في القسم 3.4: تعلّم الاتصالات الصحيحة عملية تكرارية، والتقليم متبوعًا بإعادة التدريب تكرار واحد، وبعد تكرارات كثيرة كهذه يمكن الوصول إلى أقل عدد من الاتصالات. كل تكرار هو بحث جشع (greedy search) عن أفضل الاتصالات. وجرّبوا أيضًا تقليم المعاملات احتماليًا بحسب قيمتها المطلقة فوجدوا أنه يعطي نتائج أسوأ.

The loop arrow from Train Weights back to Prune Connections. Each pass raises the target (30, 50, 70, 80, 90 percent) and the 6 by 6 matrix loses its smallest survivors until four weights remain, a 9x ratio.سهم الحلقة من Train Weights عائدًا إلى Prune Connections. كل مرور يرفع الهدف (30 و50 و70 و80 و90 بالمئة)، والمصفوفة 6 في 6 تفقد أصغر أوزانها الباقية حتى يبقى أربعة أوزان فقط، أي نسبة 9x.

Why gradual beats one-shotلماذا يتفوّق التدريج على القطع دفعة واحدة

The magnitude criterion ranks weights on the network as it is right now. After a 30% cut and a fine-tune, the survivors have re-settled: some grew to cover the removed terms, some shrank because their job was taken over. The ranking for the next cut is therefore measured on a network that has adapted, and the weights it marks as small really are the least needed. A one-shot cut to 90% ranks all 90% on a network that has never adapted to any loss, so it discards weights that would have become important once their neighbors were gone. Zhu and Gupta describe the same principle in the general form of a sparsity schedule: the binary mask is updated every few hundred steps to gradually increase the sparsity of the network while allowing the training steps to recover from any pruning-induced loss in accuracy. Their cubic schedule prunes quickly at first, when redundant connections are abundant, and slowly near the end.

معيار المقدار يرتّب الأوزان على الشبكة كما هي الآن. بعد قطع 30% وعمل fine-tune، تكون الأوزان الباقية قد استقرّت من جديد: بعضها كبر ليغطي الحدود المحذوفة، وبعضها صغر لأن غيره تولّى عمله. لذلك فإن الترتيب للقطع التالي يُقاس على شبكة تكيّفت، والأوزان التي يعلّمها بأنها صغيرة هي فعلًا الأقل حاجة. أما القطع دفعة واحدة إلى 90% فيرتّب الـ 90% كلها على شبكة لم تتكيّف مع أي فقدان، فيتخلّص من أوزان كانت ستصبح مهمة بعد ذهاب جيرانها. يصف Zhu وGupta المبدأ نفسه في صورته العامة كجدول sparsity: يُحدَّث الـ binary mask كل بضع مئات من الخطوات لرفع sparsity الشبكة تدريجيًا، مع السماح لخطوات التدريب بأن تتعافى من أي فقدان في الدقة سبّبه التقليم. وجدولهم التكعيبي (cubic) يقلّم بسرعة في البداية، حين تكون الاتصالات الزائدة وفيرة، وببطء قرب النهاية.

st=sf+(si−sf)(1−t−t0n Δt)3s_t = s_f + (s_i - s_f)\left(1 - \frac{t - t_0}{n\,\Delta t}\right)^3
Zhu and Gupta's gradual schedule: sparsity ramps from s_i (usually 0) to s_f over n pruning steps spaced delta t apartالجدول التدريجي لـ Zhu وGupta: يرتفع التناثر من s_i (عادةً 0) إلى s_f عبر n خطوة تقليم تفصل بينها delta t

The schedule in this part uses five hand-picked targets rather than a closed form, but the shape is the same: larger cuts early, smaller ones late. On a 6 x 6 matrix of 36 weights, rounding 36 s gives the following zero counts, which are also what the simulator below shows.

الجدول في هذا الجزء يستخدم خمسة أهداف مختارة يدويًا بدل صيغة مغلقة، لكن الشكل واحد: قطعات أكبر في البداية، وأصغر في النهاية. على مصفوفة 6 x 6 من 36 وزنًا، تقريب 36 s يعطي أعداد الأصفار التالية، وهي أيضًا ما يعرضه المحاكي أدناه.

TargetالهدفZerosالأصفارNonzeros leftغير الصفرية الباقيةActual sparsityالـ sparsity الفعليةRatioالنسبة
30%30%1111252530.6%30.6%1.4x1.4x
50%50%1818181850.0%50.0%2.0x2.0x
70%70%2525111169.4%69.4%3.3x3.3x
80%80%29297780.6%80.6%5.1x5.1x
90%90%32324488.9%88.9%9.0x9.0x
A five-step schedule on 36 weights (zeros = round(36 s))جدول من خمس خطوات على 36 وزنًا (عدد الأصفار = round(36 s))
SimulatorمحاكيIterative pruning stepper: a 6 by 6 weight matrix on a sparsity scheduleمتتبع التقليم التكراري: مصفوفة أوزان 6 في 6 على جدول تناثر
+0.5%0%-1%-2%-3%-4%40%50%60%70%80%90%100%parameters pruned awayone-shot + fine-tuneiterative
Nonzeros36of 36
Sparsity0%zerosno target applied yetلم يُطبق أي هدف بعد
Compression1.0xratio36 / 36
Toy loss0.0%iterative curveالمنحنى التكراري
The matrix starts dense with 36 nonzeros. Each press prunes the smallest survivors to the next target in the schedule 30%, 50%, 70%, 80%, 90% and then fine-tunes what is left.تبدأ المصفوفة كثيفة بـ 36 قيمة غير صفرية. كل ضغطة تقلّم أصغر القيم الباقية حتى الهدف التالي في الجدول 30%, 50%, 70%, 80%, 90%، ثم تضبط ما تبقى ضبطًا دقيقًا.

Illustrative only. Fine-tuning is stood in for by letting each surviving weight in a row absorb 0.5 of the magnitude its row just lost, an echo of the surviving weights spreading outward in Han et al. Figure 7. The two loss curves are shape fits to the green and red curves of slide 51, not measured data. Cells with a teal border were zeroed in the latest step; survivors with a bright border moved up the magnitude ranking.للتوضيح فقط. يُحاكى الضبط الدقيق بأن يمتص كل وزن باقٍ في الصف 0.5 من المقدار الذي خسره صفه للتو، صدى لانتشار الأوزان الباقية نحو الخارج في الشكل 7 من Han et al.. منحنيا الخسارة مطابقة شكلية للمنحنيين الأخضر والأحمر في الشريحة 51، وليسا بيانات مقيسة. الخلايا ذات الحد الأزرق المخضر صُفّرت في الخطوة الأخيرة، والأوزان الباقية ذات الحد الساطع ارتفعت في ترتيب المقدار.

The loop also connects backwards to part 05. NetAdapt runs a short-term fine-tune after every layer it thins and a long-term fine-tune at the end, which is the same prune-then-fine-tune loop driven by a latency budget instead of a sparsity schedule. Whatever criterion or granularity you choose, the outer loop looks like this figure.

الحلقة ترتبط أيضًا بالجزء 05 السابق. الـ NetAdapt يشغّل short-term fine-tune بعد كل طبقة يرقّقها، وlong-term fine-tune في النهاية، وهذه هي حلقة التقليم ثم الـ fine-tune نفسها لكن تقودها ميزانية زمن استجابة (latency) بدل جدول sparsity. أيًا كان المعيار أو الدقة (granularity) التي تختارها، فإن الحلقة الخارجية تبدو مثل هذا الشكل.

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

In iterative pruning, what exactly counts as one iteration?في الـ iterative pruning، ما الذي يُعدّ بالضبط تكرارًا واحدًا؟

Recall

Define one iteration of iterative pruning and say what changes between iterations.عرّف التكرار الواحد في الـ iterative pruning، وقل ما الذي يتغيّر بين التكرارات.

Prune, then fine-tune (retrain the surviving weights). The target sparsity is raised each iteration, and the weights removed are the smallest survivors of the previous round.
قلّم، ثم اعمل fine-tune (أعِد تدريب الأوزان الباقية). الـ sparsity المستهدفة ترتفع في كل تكرار، والأوزان التي تُحذف هي أصغر الأوزان الباقية من الجولة السابقة.

Slide 51 adds one bullet and one curve, and together they carry the number you will be asked for: Iterative pruning boosts the Pruning ratio from 5x to 9x on AlexNet compared to single-step aggressive pruning. The red curve is what that sentence looks like.

تضيف الشريحة 51 نقطة واحدة ومنحنى واحدًا، ومعًا يحملان الرقم الذي ستُسأل عنه: الـ iterative pruning يرفع الـ pruning ratio من 5x إلى 9x على AlexNet مقارنةً بالتقليم العنيف بخطوة واحدة (single-step aggressive pruning). المنحنى الأحمر هو الصورة البيانية لهذه الجملة.

The slide 51 chart redrawn from its read-off points. The teal prune plus fine-tune curve draws first, then the violet iterative curve. The 5x line marks where a single aggressive cut lands, the 9x line where iterative pruning still shows no loss.رسم الشريحة 51 مُعاد رسمه من النقاط المقروءة منه. يُرسم أولًا منحنى التقليم مع fine-tune باللون الفيروزي، ثم المنحنى التكراري باللون البنفسجي. الخط 5x يحدد أين ينتهي قطع عنيف واحد، والخط 9x يحدد أين لا يزال الـ iterative pruning بلا أي فقدان.
CurveالمنحنىWithin 0.5% loss up toضمن فقدان 0.5% حتىReaches about -4% atيصل إلى نحو -4% عند
Pruning onlyالتقليم فقطabout 60%نحو 60%about 80% (5x)نحو 80% (5x)
Pruning + fine-tuningالتقليم مع fine-tuningabout 85%نحو 85%about 93% (14x)نحو 93% (14x)
Iterative pruning + fine-tuningالتقليم التكراري مع fine-tuningabout 92% (12.5x)نحو 92% (12.5x)about 95.5% (22x)نحو 95.5% (22x)
How far each curve goes before the loss becomes visibleإلى أي مدى يصل كل منحنى قبل أن يظهر الفقدان
Pruned awayالنسبة المقلَّمةAccuracy lossفقدان الدقة
87.5%87.5%+0.1+0.1
89%89%+0.05+0.05
90%90%0.00.0
91.5%91.5%-0.3-0.3
92.5%92.5%-0.6-0.6
93.5%93.5%-1.0-1.0
94.5%94.5%-2.0-2.0
95.5%95.5%-4.1-4.1
Iterative pruning points read off the slide 51 chartنقاط التقليم التكراري كما تُقرأ من رسم الشريحة 51

Notice where the curve begins. It does not start at 40% like the others. The paper explains why in section 5: the biggest gain comes from iterative pruning, where the pruned and retrained network of the green curve is pruned and retrained again. The leftmost red dot corresponds to the point on the green line at 80% (5x) pruned further to 8x. There is no accuracy loss at 9x, and not until 10x does the accuracy begin to drop sharply.

لاحظ أين يبدأ المنحنى. فهو لا يبدأ من 40% مثل المنحنيات الأخرى. تشرح الورقة السبب في القسم 5: أكبر مكسب يأتي من الـ iterative pruning، حيث تُقلَّم الشبكة التي قُلّمت وأُعيد تدريبها في المنحنى الأخضر ثم يُعاد تدريبها مرة أخرى. أقصى نقطة حمراء على اليسار تقابل النقطة على الخط الأخضر عند 80% (5x) بعد تقليمها أكثر إلى 8x. لا يوجد فقدان في الدقة عند 9x، ولا تبدأ الدقة بالانخفاض الحاد إلا عند 10x.

Worked exampleمثال محلول

The 5x to 9x claim in parametersادعاء 5x إلى 9x بلغة عدد المعاملات

  1. Single-step toleranceتحمّل الخطوة الواحدة

    5x of 61M leaves 12.2M weights, which is 80% pruned away.
    5x من 61M يُبقي 12.2M وزن، أي أن 80% قد قُلّمت.
  2. Iterative resultالنتيجة التكرارية

    9x leaves about 6.8M; the paper's measured count is 6.7M (61 / 6.7 = 9.1x, quoted as 9x), at about 89% pruned away.
    9x يُبقي نحو 6.8M؛ والعدد المقيس في الورقة هو 6.7M (61 / 6.7 = 9.1x، ويُذكر على أنه 9x)، أي نحو 89% مقلَّمة.
  3. What the extra iterations removedما أزالته التكرارات الإضافية

    12.2M - 6.8M = 5.4M further weights, 44% of what single-step pruning had kept, at no accuracy cost.
    12.2M - 6.8M = 5.4M وزن إضافي، أي 44% مما كان التقليم بخطوة واحدة قد أبقاه، دون أي كلفة في الدقة.
  4. Where it stopsأين يتوقف

    10x would be 6.1M weights, and there the paper reports the accuracy beginning to drop sharply.
    10x يعني 6.1M وزن، وهناك تذكر الورقة أن الدقة تبدأ بالانخفاض الحاد.

The same paper reaches 13x on VGG-16 with five iterations of pruning and retraining, shrinking it to 7.5% of its original size with fc6 and fc7 each pruned to less than 4% of their original size. These pruned networks are the starting point of Deep Compression, which quantizes the surviving weights to 8 bits in convolution layers and 5 bits in fully connected layers and Huffman codes the result to reach 35x on AlexNet (240 MB to 6.9 MB) and 49x on VGG-16. The roughly 90% Weight sparsity that EIE assumes in the next part is this number.

الورقة نفسها تصل إلى 13x على VGG-16 بخمسة تكرارات من التقليم وإعادة التدريب، فتصغّرها إلى 7.5% من حجمها الأصلي، مع تقليم كل من fc6 وfc7 إلى أقل من 4% من حجمها الأصلي. هذه الشبكات المقلَّمة هي نقطة انطلاق Deep Compression، الذي يحوّل الأوزان الباقية بالـ quantization إلى 8 بت في طبقات الـ convolution و5 بت في طبقات الـ fully connected، ثم يرمّز النتيجة بـ Huffman coding ليصل إلى 35x على AlexNet (من 240 MB إلى 6.9 MB) و49x على VGG-16. والـ weight sparsity البالغة نحو 90% التي يفترضها EIE في الجزء التالي هي هذا الرقم.

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

On AlexNet, iterative pruning raised the achievable pruning ratio from what to what?على AlexNet، رفع الـ iterative pruning نسبة التقليم الممكنة من كم إلى كم؟

Recall

Quote the AlexNet number for iterative versus single-step pruning and convert both to percent pruned.اذكر رقم AlexNet للتقليم التكراري مقابل التقليم بخطوة واحدة، وحوّل كليهما إلى نسبة مئوية مقلَّمة.

5x to 9x, which is 80% and 88.9% pruned away. 61M to 6.7M parameters, top-5 error 19.73% to 19.67%.
من 5x إلى 9x، أي 80% و88.9% مقلَّمة. من 61M إلى 6.7M معامل، وخطأ top-5 من 19.73% إلى 19.67%.

Fine-tuning repairs the network after the cut. Regularization (for pruning) prepares it before the cut. Follow one weight w = 0.05 through training with a penalty coefficient lambda = 0.01 and a learning rate eta = 0.1, ignoring the data loss for the moment so only the penalty acts.

الـ Fine-tuning يصلح الشبكة بعد القطع. والـ regularization يجهّزها قبل القطع. تتبّع وزنًا واحدًا w = 0.05 عبر التدريب مع معامل عقوبة lambda = 0.01 ومعدل تعلّم eta = 0.1، متجاهلًا خسارة البيانات مؤقتًا حتى تعمل العقوبة وحدها.

Worked exampleمثال محلول

One weight under an L1 and an L2 penaltyوزن واحد تحت عقوبة L1 وعقوبة L2

  1. L1 pullسحب الـ L1

    The gradient of lambda |w| is lambda sign(w), so each step subtracts eta lambda = 0.001 regardless of how small w is. From 0.05 the weight reaches exactly zero in 50 steps and stays there.
    مشتقة lambda |w| هي lambda sign(w)، لذلك كل خطوة تطرح eta lambda = 0.001 مهما كان w صغيرًا. من 0.05 يصل الوزن إلى الصفر تمامًا في 50 خطوة ويبقى هناك.
  2. L2 pullسحب الـ L2

    The gradient of lambda w^2 is 2 lambda w, so each step subtracts eta 2 lambda w = 0.002 w. The weight is multiplied by 0.998 every step: after 50 steps 0.05 x 0.998^50 = 0.0452, after 1000 steps 0.0068, never zero.
    مشتقة lambda w^2 هي 2 lambda w، لذلك كل خطوة تطرح eta 2 lambda w = 0.002 w. يُضرب الوزن في 0.998 في كل خطوة: بعد 50 خطوة 0.05 x 0.998^50 = 0.0452، وبعد 1000 خطوة 0.0068، ولا يصل إلى الصفر أبدًا.
  3. Two different destinationsوجهتان مختلفتان

    L1 subtracts a constant and lands on zero. L2 multiplies by a constant and only approaches it.
    الـ L1 يطرح مقدارًا ثابتًا فيستقر عند الصفر. والـ L2 يضرب في معامل ثابت فيقترب من الصفر فقط.
StepsالخطواتL1L1L2L2
000.05000.05000.05000.0500
50500.00000.00000.04520.0452
2002000.00000.00000.03350.0335
100010000.00000.00000.00680.0068
w after n steps with only the penalty actingقيمة w بعد n خطوة مع عمل العقوبة وحدها
Five weights slide down each penalty. Under |w| every dot reaches the vertex at zero and lands inside the pruning threshold band; under w squared each dot stops at 30 percent of where it started, and the large ones stay outside the band.خمسة أوزان تنزلق على كل عقوبة. تحت |w| تصل كل نقطة إلى الرأس عند الصفر وتستقر داخل نطاق عتبة التقليم؛ وتحت w تربيع تتوقف كل نقطة عند 30 بالمئة من موضع بدايتها، وتبقى الأوزان الكبيرة خارج النطاق.

The two regularized lossesدالتا الخسارة مع الـ regularization

The slide states the general rule. During training, or during the fine-tuning of a pruned network, a penalty is added to the loss to penalize nonzero parameters and to encourage smaller ones. The two common choices are the L1 and L2 penalties on the weights W, with lambda setting how strongly the penalty competes with the data loss L(x; W).

تذكر الشريحة القاعدة العامة. أثناء التدريب، أو أثناء الـ fine-tuning لشبكة مقلَّمة، تُضاف عقوبة إلى الخسارة لمعاقبة المعاملات غير الصفرية وتشجيع المعاملات الأصغر. الخياران الشائعان هما عقوبتا L1 وL2 على الأوزان W، حيث يحدد lambda مدى قوة منافسة العقوبة لخسارة البيانات L(x; W).

L′=L(x;W)+λ ∣W∣L' = L(\mathbf{x};\mathbf{W}) + \lambda\,|\mathbf{W}|
L1 regularization: the penalty is the sum of absolute valuesتنظيم L1: العقوبة هي مجموع القيم المطلقة
L′=L(x;W)+λ ∥W∥2L' = L(\mathbf{x};\mathbf{W}) + \lambda\,\|\mathbf{W}\|^2
L2 regularization: the penalty is the squared L2 norm, also called weight decayتنظيم L2: العقوبة هي مربع معيار L2، ويُسمى أيضًا weight decay
∂L′∂w=∂L∂w+λ sign(w)versus∂L′∂w=∂L∂w+2λw\frac{\partial L'}{\partial w} = \frac{\partial L}{\partial w} + \lambda\,\mathrm{sign}(w) \quad\text{versus}\quad \frac{\partial L'}{\partial w} = \frac{\partial L}{\partial w} + 2\lambda w
The gradients explain the behavior: L1's pull is constant near zero, L2's vanishesالتدرجات تفسر السلوك: شدّ L1 ثابت قرب الصفر، أما شدّ L2 فيتلاشى

Goodfellow, Bengio and Courville make both halves precise. L2 regularization, commonly known as weight decay, drives the weights closer to the origin; its update multiplicatively shrinks the weight vector by a constant factor on each step (their equation 7.5). L1 regularization, in comparison, results in a solution that is more sparse, where sparsity means that some parameters have an optimal value of exactly zero, and this property is why L1 has been used extensively for feature selection (LASSO). The gradient forms above are the reason. Near zero the L1 gradient lambda sign(w) keeps its full size, so the weight is pushed onto zero and pinned there. The L2 gradient 2 lambda w shrinks with the weight, so the push fades before it arrives.

يجعل Goodfellow وBengio وCourville الجانبين دقيقين. الـ L2 regularization، المعروف عادةً باسم weight decay، يقرّب الأوزان من نقطة الأصل؛ وتحديثه يقلّص متجه الأوزان بشكل ضربي بمعامل ثابت في كل خطوة (معادلتهم 7.5). أما الـ L1 regularization فيؤدي بالمقارنة إلى حل أكثر تفرّقًا (sparse)، حيث يعني التفرّق أن بعض المعاملات قيمتها المثلى صفر تمامًا، وهذه الخاصية هي سبب استخدام الـ L1 على نطاق واسع لاختيار السمات (LASSO). وصيغ المشتقات أعلاه هي السبب. قرب الصفر تحافظ مشتقة الـ L1، lambda sign(w)، على حجمها الكامل، فيُدفع الوزن إلى الصفر ويُثبَّت هناك. أما مشتقة الـ L2، 2 lambda w، فتصغر مع الوزن، فيخفت الدفع قبل أن يصل.

L1L1L2L2
Gradient of the penaltyمشتقة العقوبةlambda sign(w), constantlambda sign(w)، ثابتة2 lambda w, shrinks with w2 lambda w، تصغر مع w
Effect per stepالأثر في كل خطوةSubtract a fixed amountطرح مقدار ثابتMultiply by a factor below oneالضرب في معامل أقل من واحد
Where weights endأين تنتهي الأوزانExactly zero, then stayعند الصفر تمامًا، وتبقى هناكSmall but never zeroصغيرة لكنها لا تصبح صفرًا أبدًا
Accuracy before retraining (Han et al.)الدقة قبل إعادة التدريب (Han et al.)BetterأفضلWorseأسوأ
Accuracy after retraining (Han et al.)الدقة بعد إعادة التدريب (Han et al.)WorseأسوأBetter, best overallأفضل، والأفضل إجمالًا
L1 versus L2 as preparation for magnitude pruningالـ L1 مقابل الـ L2 كتحضير للـ magnitude pruning

Why both help pruning, and why L2 won anywayلماذا يساعد كلاهما التقليم، ولماذا فاز الـ L2 مع ذلك

Either penalty shrinks the weights the data loss does not defend. That does two things for magnitude pruning. The ranking becomes a cleaner signal, because a weight that stayed large did so against a constant pull, and the mass of the distribution near zero grows, so more weights fall under the threshold at a given accuracy. L1 goes further and parks weights on exactly zero, so removing them changes nothing at all.

أي من العقوبتين يقلّص الأوزان التي لا تدافع عنها خسارة البيانات. وهذا يفيد الـ magnitude pruning بأمرين. يصبح الترتيب إشارة أنظف، لأن الوزن الذي بقي كبيرًا فعل ذلك رغم سحب ثابت، وتزداد كتلة التوزيع قرب الصفر، فيقع عدد أكبر من الأوزان تحت العتبة عند دقة معيّنة. والـ L1 يذهب أبعد فيثبّت الأوزان عند الصفر تمامًا، فلا تغيّر إزالتها شيئًا على الإطلاق.

It is tempting to conclude that L1 must be the better choice for pruning, and this is the classic trap. Han et al. (section 3.1) report that L1 regularization does give better accuracy after pruning but before retraining, since more parameters sit near zero. However, the remaining connections are not as good as with L2, resulting in lower accuracy after retraining, and overall L2 regularization gives the best pruning results. They also tried L1 for the pruning phase followed by L2 for retraining and found it did not beat using L2 for both, because parameters from one mode do not adapt well to the other. That is why the slide says magnitude-based fine-grained pruning applies L2 regularization on weights.

من المغري أن تستنتج أن الـ L1 لا بد أن يكون الخيار الأفضل للتقليم، وهذا هو الفخ الكلاسيكي. يذكر Han et al. (القسم 3.1) أن الـ L1 regularization يعطي فعلًا دقة أفضل بعد التقليم وقبل إعادة التدريب، لأن عددًا أكبر من المعاملات يكون قرب الصفر. لكن الاتصالات الباقية ليست بجودة ما يتركه الـ L2، فتكون الدقة بعد إعادة التدريب أقل، وإجمالًا يعطي الـ L2 regularization أفضل نتائج تقليم. وجرّبوا أيضًا الـ L1 لمرحلة التقليم ثم الـ L2 لإعادة التدريب، فوجدوا أنه لا يتفوّق على استخدام الـ L2 في المرحلتين، لأن المعاملات القادمة من نمط لا تتكيّف جيدًا مع النمط الآخر. ولهذا تقول الشريحة إن الـ magnitude-based fine-grained pruning يطبّق الـ L2 regularization على الأوزان.

Network Slimming: the same penalty on channel scaling factorsNetwork Slimming: العقوبة نفسها على معاملات تحجيم القنوات

The second example on the slide moves the penalty from weights to channels, which connects back to the scaling-based criterion of lecture 04-1. Network Slimming (Liu et al., ICCV 2017) notes that every batch normalization layer already computes z_out = gamma z_hat + beta per channel, so gamma is a free scaling factor for that channel. Their training objective adds a sparsity penalty on those factors.

المثال الثاني في الشريحة ينقل العقوبة من الأوزان إلى القنوات، وهذا يعيدنا إلى المعيار المبني على التحجيم (scaling-based) في المحاضرة 04-1. يلاحظ Network Slimming (Liu et al.، ICCV 2017) أن كل طبقة batch normalization تحسب أصلًا z_out = gamma z_hat + beta لكل قناة، لذلك فإن gamma معامل تحجيم مجاني لتلك القناة. ودالة الهدف في تدريبهم تضيف عقوبة sparsity على تلك المعاملات.

L=∑(x,y)l(f(x,W),y)+λ∑γ∈Γg(γ),g(s)=∣s∣L = \sum_{(x,y)} l\big(f(x, W), y\big) + \lambda \sum_{\gamma \in \Gamma} g(\gamma), \qquad g(s) = |s|
Network Slimming objective (Liu et al. 2017, equation 1): an L1 penalty on the batch norm scaling factorsهدف Network Slimming (Liu et al. 2017، المعادلة 1): عقوبة L1 على معاملات التحجيم في batch norm

Channels whose gamma has been pushed toward zero contribute almost nothing and are removed with a global percentile threshold (pruning 70% of channels means choosing the 70th percentile of all gamma values), followed by fine-tuning. Because a whole channel goes, this is Channel pruning, the coarse end of Pruning granularity, and the resulting network stays dense. On VGGNet the method reports a 20x smaller model and 5x fewer computing operations. The paper also describes a multi-pass scheme that repeats train, prune and fine-tune, the same loop as the previous concepts, now driven by gamma instead of |w|.

القنوات التي دُفع gamma الخاص بها نحو الصفر لا تساهم بشيء تقريبًا، وتُزال بعتبة مئينية عامة (global percentile threshold)؛ فتقليم 70% من القنوات يعني اختيار المئين 70th من كل قيم gamma، ثم يتبع ذلك fine-tuning. ولأن القناة تُحذف كاملة، فهذا channel pruning، أي الطرف الخشن من pruning granularity، والشبكة الناتجة تبقى كثيفة (dense). على VGGNet تذكر الطريقة نموذجًا أصغر بـ 20x وعمليات حسابية أقل بـ 5x. وتصف الورقة أيضًا مخططًا متعدد المرور يكرر التدريب ثم التقليم ثم الـ fine-tune، وهي الحلقة نفسها في المفاهيم السابقة، لكن يقودها الآن gamma بدل |w|.

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

Why does an L1 penalty drive weights exactly to zero while L2 only shrinks them?لماذا تدفع عقوبة L1 الأوزان إلى الصفر تمامًا بينما تكتفي L2 بتقليصها؟

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

Network Slimming applies its sparsity penalty to which quantity?على أي كمية يطبّق Network Slimming عقوبة الـ sparsity؟

Recall

Write the L1 and L2 regularized losses and say which one produces exact zeros.اكتب دالتَي الخسارة مع الـ L1 والـ L2 regularization، وقل أيّهما يُنتج أصفارًا تامة.

L' = L(x; W) + lambda |W| and L' = L(x; W) + lambda ||W||^2. L1: its gradient lambda sign(w) is constant near zero, so weights land on zero. L2: its gradient 2 lambda w vanishes as w shrinks, so weights only get smaller.
L' = L(x; W) + lambda |W| وL' = L(x; W) + lambda ||W||^2. الـ L1: مشتقته lambda sign(w) ثابتة قرب الصفر، فتستقر الأوزان عند الصفر. الـ L2: مشتقته 2 lambda w تتلاشى مع صغر w، فتصغر الأوزان فقط.

Recall

Which regularizer did Han et al. find best overall for pruning, and what does Network Slimming penalize?أي regularizer وجده Han et al. الأفضل إجمالًا للتقليم، وما الذي يعاقبه Network Slimming؟

L2 on the weights (L1 is better before retraining, worse after). Network Slimming puts an L1 penalty on the batch normalization scaling factors gamma of each channel.
الـ L2 على الأوزان (الـ L1 أفضل قبل إعادة التدريب، وأسوأ بعدها). أما Network Slimming فيضع عقوبة L1 على معاملات التحجيم gamma في الـ batch normalization لكل قناة.

Recapالخلاصة

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

  • Pruning without retraining starts losing accuracy once only one third of the original connections remain (about 67 percent pruned). One prune plus fine-tune holds to about 80 percent, and the full retraining scheme reaches one tenth remaining (Han et al.).التقليم دون إعادة تدريب يبدأ بفقدان الدقة عندما يبقى ثلث الاتصالات الأصلية فقط (أي نحو 67 بالمئة مقلَّمة). أما تقليم واحد مع fine-tune فيصمد حتى نحو 80 بالمئة، ومخطط إعادة التدريب الكامل يصل إلى بقاء العُشر فقط (Han et al.).
  • Fine-tuning retrains only the survivors, with the mask fixed, at 1/10 to 1/100 of the original learning rate. AlexNet took 173 hours to retrain versus 75 hours to train.الـ fine-tuning يعيد تدريب الأوزان الباقية فقط، مع تثبيت الـ mask، بمعدل تعلّم يساوي 1/10 إلى 1/100 من المعدل الأصلي. استغرقت إعادة تدريب AlexNet 173 ساعة مقابل 75 ساعة للتدريب الأصلي.
  • One iteration is prune then fine-tune. Iterative pruning raises the target sparsity each round and lifted AlexNet from 5x to 9x (61M to 6.7M parameters, top-5 error 19.73 to 19.67 percent).التكرار الواحد هو تقليم ثم fine-tune. الـ iterative pruning يرفع الـ sparsity المستهدفة في كل جولة، وقد رفع AlexNet من 5x إلى 9x (من 61M إلى 6.7M معامل، وخطأ top-5 من 19.73 إلى 19.67 بالمئة).
  • On the curve, iterative pruning stays within 0.5 percent loss to about 92 percent pruned and reaches -4 percent only near 95.5 percent; single prune plus fine-tune holds zero loss only to 80 percent (5x).على المنحنى، يبقى الـ iterative pruning ضمن فقدان 0.5 بالمئة حتى نحو 92 بالمئة مقلَّمة، ولا يصل إلى -4 بالمئة إلا قرب 95.5 بالمئة؛ أما تقليم واحد مع fine-tune فيحافظ على فقدان صفري حتى 80 بالمئة فقط (5x).
  • L1 (lambda |W|) parks weights at exact zero; L2 (lambda ||W||^2) shrinks every weight multiplicatively. Both make small weights cheaper to remove.الـ L1 (lambda |W|) يثبّت الأوزان عند الصفر تمامًا؛ والـ L2 (lambda ||W||^2) يقلّص كل وزن بشكل ضربي. كلاهما يجعل إزالة الأوزان الصغيرة أقل كلفة.
  • Han et al. found L2 best overall for magnitude pruning; Network Slimming puts an L1 penalty on batch norm scaling factors to select channels, and its multi-pass scheme is the same loop.وجد Han et al. أن الـ L2 هو الأفضل إجمالًا للـ magnitude pruning؛ أما Network Slimming فيضع عقوبة L1 على معاملات التحجيم في الـ batch norm لاختيار القنوات، ومخططه متعدد المرور هو الحلقة نفسها.
  • Deep Compression and EIE (next part) start from exactly this 9x to 13x pruned network.الـ Deep Compression والـ EIE (الجزء التالي) يبدآن من هذه الشبكة المقلَّمة بنسبة 9x إلى 13x تحديدًا.

Sourcesالمصادر