COE 592Lecture 5.1المحاضرة 5.1Part 05الجزء 05
K-means weight quantization: codebook, storage and centroid fine-tuningتكميم الأوزان بـK-means: دفتر الترميز والتخزين وضبط المراكز
Cluster weights with K-means, store 2-bit cluster indexes plus a 32-bit codebook, compute the compression ratio, and fine-tune centroids by grouping gradients by cluster index and summing them.جمّع الأوزان بـK-means، وخزّن فهارس عناقيد من 2 بت مع دفتر ترميز (codebook) من 32 بت، واحسب نسبة الضغط، واضبط المراكز (centroids) بتجميع التدرجات حسب فهرس العنقود وجمعها.
- Conceptsالمفاهيم
- 4
- Slidesالشرائح
- 26-29
- Readingمدة القراءة
- 24 min24 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
A trained network stores every weight as a 32-bit float, yet many weights sit so close together that the network would barely notice if they shared one value. This part turns that observation into a working compression method: cluster the weights, keep only a short index per weight and a tiny table of shared values, then retrain the table so the network recovers its accuracy.
Everything here follows Figure 3 of Deep Compression (Han, Mao and Dally, ICLR 2016), the same 4 × 4 example the slides use. For the midterm, expect three kinds of question: the storage bill for given and , the fine-tuned centroids for a given gradient matrix and learning rate, and why the index map does not change during fine-tuning. For embedded work, this is the method that lets a model ship at a fraction of its size while the arithmetic stays in floating point.
الشبكة المدرَّبة تخزّن كل وزن كعدد عشري بحجم 32-bit، ومع ذلك فكثير من الأوزان قريبة جدًا من بعضها لدرجة أن الشبكة بالكاد ستلاحظ الفرق لو تشاركت قيمة واحدة. هذا الجزء يحوّل هذه الملاحظة إلى طريقة ضغط عملية: جمّع الأوزان في مجموعات، واحتفظ فقط بفهرس قصير لكل وزن وجدول صغير جدًا من القيم المشتركة، ثم أعد تدريب هذا الجدول حتى تستعيد الشبكة دقتها.
كل ما هنا يتبع الشكل 3 من ورقة Deep Compression (Han, Mao and Dally, ICLR 2016)، وهو نفس مثال 4 × 4 الذي تستخدمه الشرائح. في الاختبار النصفي توقّع ثلاثة أنواع من الأسئلة: حساب التخزين لقيم معطاة من و ، والمراكز بعد الـ fine-tuning لمصفوفة gradients ومعدل تعلم معطيين، ولماذا لا تتغير خريطة الفهارس أثناء الـ fine-tuning. وفي الأنظمة المدمجة، هذه هي الطريقة التي تسمح بشحن النموذج بجزء صغير من حجمه بينما تبقى العمليات الحسابية بالفاصلة العائمة (floating point).
By the end you canفي نهاية هذا الجزء ستستطيع
- Cluster a small weight matrix with K-means and explain why each centroid is the mean of its cluster.تجميع مصفوفة أوزان صغيرة باستخدام K-means، وشرح لماذا يكون كل مركز (centroid) هو متوسط عناصر مجموعته.
- Turn a clustering into an index matrix plus a codebook, rebuild the weights and read the quantization error.تحويل نتيجة التجميع إلى مصفوفة فهارس (index matrix) زائد دفتر رموز (codebook)، ثم إعادة بناء الأوزان وقراءة خطأ التكميم (quantization error).
- Compute storage before and after for any N and M, and explain why the ratio approaches 32/N only when M is much larger than 2^N.حساب حجم التخزين قبل وبعد لأي N و M، وشرح لماذا تقترب النسبة من 32/N فقط عندما تكون M أكبر بكثير من 2^N.
- Derive the centroid gradient as the sum of the gradients of every weight that shares it.اشتقاق gradient المركز على أنه مجموع gradients كل الأوزان التي تشترك فيه.
- Fine-tune a codebook by hand: group by index, reduce by sum, multiply by the learning rate and subtract.ضبط دفتر الرموز (fine-tuning) يدويًا: جمّع حسب الفهرس، اختزل بالجمع، اضرب في معدل التعلم (learning rate) ثم اطرح.
Once the clustering is fixed, the original matrix can be thrown away. In its place you store two things: a 4 × 4 matrix of small integers saying which cluster each weight belongs to, and a list of four floats saying what each cluster's value is.
بمجرد تثبيت التجميع يمكن التخلص من المصفوفة الأصلية. وتخزّن مكانها شيئين: مصفوفة 4 × 4 من أعداد صحيحة صغيرة تقول إلى أي مجموعة ينتمي كل وزن، وقائمة من أربعة أعداد عشرية تقول ما قيمة كل مجموعة.
Two tables replace oneجدولان بدلًا من جدول واحد
The integer matrix is the map of Cluster index values. With clusters an index needs bits, so slide 27 labels it 2-bit int. Its first row is 3, 0, 2, 1. The list of floats is the Codebook: 3: 2.00, 2: 1.50, 1: 0.00, 0: -1.00. Notice the indexes are numbered in increasing centroid order, so index 0 is the most negative value.
مصفوفة الأعداد الصحيحة هي خريطة قيم cluster index (فهرس المجموعة). مع مجموعات يحتاج الفهرس إلى بت، ولذلك تسمّيها الشريحة 27 باسم 2-bit int. صفها الأول هو 3, 0, 2, 1. أما قائمة الأعداد العشرية فهي codebook (دفتر الرموز): 3: 2.00 و 2: 1.50 و 1: 0.00 و 0: -1.00. لاحظ أن الفهارس مرقّمة بترتيب تصاعدي للمراكز، فالفهرس 0 هو القيمة الأكثر سالبية.
To use the layer you rebuild each weight by looking up its index in the codebook. Index 3 becomes 2.00, index 0 becomes -1.00, and so on. The rebuilt matrix is:
لاستخدام الطبقة تعيد بناء كل وزن بالبحث عن فهرسه في دفتر الرموز. الفهرس 3 يصبح 2.00، والفهرس 0 يصبح -1.00، وهكذا. المصفوفة المعاد بناؤها هي:
The rebuilt weights are still 32-bit floats, which is why slide 27 labels them that way. K-means saves storage, not arithmetic: at inference the indexes are decoded through the codebook and the layer runs in floating point, the Decode (lookup) at inference step a later part covers.
الأوزان المعاد بناؤها ما زالت أعدادًا عشرية بحجم 32-bit، ولهذا تسمّيها الشريحة 27 بهذا الاسم. K-means يوفّر في التخزين لا في الحساب: عند الاستدلال (inference) تُفك الفهارس عبر دفتر الرموز وتعمل الطبقة بالفاصلة العائمة، وهي خطوة decode (lookup) التي يشرحها جزء لاحق.
What is lost: the quantization errorما الذي نخسره: خطأ التكميم
Subtracting gives the Quantization error at each position, original minus reconstructed:
الطرح يعطي quantization error (خطأ التكميم) عند كل موضع، أي الأصلي ناقص المعاد بناؤه:
The largest error in magnitude is -0.14, the weight -0.14 forced to 0.00. These small errors are what the network pays for compression, and what the fine-tuning in the next two concepts tries to win back.
أكبر خطأ في القيمة المطلقة هو -0.14، وهو الوزن -0.14 الذي أُجبر على أن يصبح 0.00. هذه الأخطاء الصغيرة هي الثمن الذي تدفعه الشبكة مقابل الضغط، وهي ما يحاول الـ fine-tuning في المفهومين التاليين استعادته.
The storage billفاتورة التخزين
Count bits. The original layer is 16 floats of 32 bits: 32 × 16 = 512 bit = 64 B. The quantized layer stores 16 indexes of 2 bits, 32 bit = 4 B, plus 4 centroids of 32 bits, 128 bit = 16 B. Total 20 B, so the layer is 64 / 20 = 3.2× smaller. That is the Compression ratio on the slide.
عُدّ البتات. الطبقة الأصلية هي 16 عددًا عشريًا كل منها 32 بت: 32 × 16 = 512 bit = 64 B. الطبقة المكمَّمة تخزّن 16 فهرسًا كل منها 2 بت، أي 32 bit = 4 B، زائد 4 مراكز كل منها 32 بت، أي 128 bit = 16 B. المجموع 20 B، فالطبقة أصغر بمقدار 64 / 20 = 3.2×. هذه هي compression ratio (نسبة الضغط) في الشريحة.
Now generalise. Take -bit indexes, so clusters, and parameters. The original costs bits. The indexes cost bits and the codebook bits.
الآن عمّم. خذ فهارس من بت، أي مجموعة، و معاملًا. الأصل يكلّف بت. الفهارس تكلّف بت، ودفتر الرموز بت.
The codebook term does not grow with . In a real layer with M = 1,000,000 and N = 4, the codebook is 16 × 32 = 512 bit against 4,000,000 bit of indexes, about 0.013% of the total. That is why the slide crosses it out.
حدّ دفتر الرموز لا يكبر مع . في طبقة حقيقية فيها M = 1,000,000 و N = 4، يكون دفتر الرموز 16 × 32 = 512 bit مقابل 4,000,000 bit من الفهارس، أي نحو 0.013% من المجموع. ولهذا تشطبه الشريحة.
Worked exampleمثال محلول
A million weights at 4 bitsمليون وزن بأربعة بتات
Originalالأصل
32 × 1,000,000 = 32,000,000 bit (4 MB).32 × 1,000,000 = 32,000,000 bit (4 MB).Indexesالفهارس
4 × 1,000,000 = 4,000,000 bit.4 × 1,000,000 = 4,000,000 bit.Codebookدفتر الرموز
2^4 = 16 centroids × 32 bits = 512 bit.2^4 = 16 مركزًا × 32 بت = 512 bit.Resultالنتيجة
32,000,000 / 4,000,512 ≈ 7.999 ≈ 8.0×, essentially 32/N = 8.32,000,000 / 4,000,512 ≈ 7.999 ≈ 8.0×، وهي عمليًا 32/N = 8.
The 4 × 4 example misses 32/2 = 16× by a wide margin because its assumption fails: with only 16 weights, the 16 B codebook is 80% of the 20 B total. Push it further and the method backfires. At N = 4 on these 16 weights, the indexes cost 64 bit but the codebook costs 512 bit, 72 B in all, larger than the 64 B original.
مثال 4 × 4 يبتعد كثيرًا عن 32/2 = 16× لأن افتراضه لا يتحقق: مع 16 وزنًا فقط، يمثّل دفتر الرموز البالغ 16 B نسبة 80% من المجموع 20 B. وإذا ذهبت أبعد تنقلب الطريقة ضدك. عند N = 4 على هذه الأوزان الـ 16، تكلّف الفهارس 64 bit لكن دفتر الرموز يكلّف 512 bit، أي 72 B إجمالًا، وهذا أكبر من الأصل البالغ 64 B.
| Itemالعنصر | Formulaالصيغة | Slide: N = 2, M = 16الشريحة: N = 2، M = 16 | Layer: N = 4, M = 10^6طبقة: N = 4، M = 10^6 |
|---|---|---|---|
| Original weightsالأوزان الأصلية | 32 bit x M32 bit x M | 32 x 16 = 512 bit = 64 B32 x 16 = 512 bit = 64 B | 32,000,000 bit32,000,000 bit |
| Indexesالفهارس | N bit x MN bit x M | 2 x 16 = 32 bit = 4 B2 x 16 = 32 bit = 4 B | 4,000,000 bit4,000,000 bit |
| Codebookدفتر الرموز (codebook) | 32 bit x 2^N = 2^(N+5) bit32 bit x 2^N = 2^(N+5) bit | 32 x 4 = 128 bit = 16 B32 x 4 = 128 bit = 16 B | 32 x 16 = 512 bit32 x 16 = 512 bit |
| Ratioالنسبة | 32M / (NM + 2^(N+5))32M / (NM + 2^(N+5)) | 64 / 20 = 3.2x64 / 20 = 3.2x | ≈ 8.0x (32/N = 8)≈ 8.0x (32/N = 8) |
The simulator runs K-means on the slide's weights. At k = 4 it reproduces slide 27 exactly. Switch to k = 2: the ratio rises to 6.4× but the errors grow to about 0.6. Switch to k = 8: the errors barely improve, three centroids own no weight at all, and the ratio falls to 1.68× because the codebook doubles.
المحاكي يشغّل K-means على أوزان الشريحة. عند k = 4 يعيد إنتاج الشريحة 27 بالضبط. انتقل إلى k = 2: ترتفع النسبة إلى 6.4× لكن الأخطاء تكبر إلى نحو 0.6. انتقل إلى k = 8: الأخطاء بالكاد تتحسن، وثلاثة مراكز لا يملك أي منها أي وزن، وتنخفض النسبة إلى 1.68× لأن دفتر الرموز يتضاعف.
- 3:2.00x4
- 2:1.50x3
- 1:0.00x5
- 0:-1.00x4
Centroids start evenly spaced between the smallest and largest weight (the linear initialisation Han et al. found best) and are rounded to two decimals for display. At k = 4 the result is exactly the slide: codebook -1.00, 0.00, 1.50, 2.00, 20 B, 3.2x.تبدأ المراكز موزعة بالتساوي بين أصغر وزن وأكبر وزن (وهي التهيئة الخطية التي وجدها Han et al. الأفضل)، وتُقرَّب إلى منزلتين عشريتين للعرض. عند k = 4 تطابق النتيجة الشريحة تماما: دفتر الرموز -1.00, 0.00, 1.50, 2.00، و20 B، و3.2x.
Quick checkاختبار سريع
A layer with one million weights is quantized with 4-bit K-means and an FP32 codebook. About how much smaller does it become?طبقة فيها مليون وزن تُكمَّم باستخدام K-means بـ 4 بت مع دفتر رموز (codebook) بصيغة FP32. بكم مرة تقريبًا يصغر حجمها؟
Recall
Why does the 4 × 4 example reach only 3.2× when 32/N predicts 16×?لماذا يصل مثال 4 × 4 إلى 3.2× فقط بينما تتوقع 32/N قيمة 16×؟
The formula 32/N assumes the codebook is negligible (M ≫ 2^N). Here the codebook is 16 B out of 20 B. Without it, 64 / 4 = 16×; with it, 64 / 20 = 3.2×.
الصيغة 32/N تفترض أن دفتر الرموز مهمل (M ≫ 2^N). هنا دفتر الرموز 16 B من أصل 20 B. بدونه تكون النسبة 64 / 4 = 16×، ومعه 64 / 20 = 3.2×.
Slide 29 turns the formula into three mechanical moves you can do with a pencil: group the gradients by colour, reduce each group to one number, then take a gradient-descent step on each centroid.
الشريحة 29 تحوّل الصيغة إلى ثلاث حركات آلية يمكنك تنفيذها بالقلم: جمّع الـ gradients حسب اللون، واختزل كل مجموعة إلى رقم واحد، ثم خذ خطوة gradient descent على كل مركز.
Group, reduce, updateجمّع، اختزل، حدّث
- Group by index. Lay the gradient matrix over the index map. Every gradient joins the group of the index at the same position. Read in row-major order, blue (index 3) collects -0.03, 0.12, 0.02, -0.07.التجميع حسب الفهرس (group by index). ضع مصفوفة الـ gradients فوق خريطة الفهارس. كل gradient ينضم إلى مجموعة الفهرس الموجود في الموضع نفسه. بالقراءة صفًا بعد صف (row-major)، يجمع الأزرق (الفهرس 3) القيم -0.03, 0.12, 0.02, -0.07.
- Reduce by sum. Add up each group. The result is .الاختزال بالجمع (reduce by sum). اجمع كل مجموعة. الناتج هو .
- Update. Multiply by the learning rate and subtract from the old centroid.التحديث (update). اضرب في معدل التعلم واطرح الناتج من المركز القديم.
Worked exampleمثال محلول
Slide 29 by handالشريحة 29 يدويًا
Group and reduceجمّع واختزل
Cluster 3: -0.03 + 0.12 + 0.02 - 0.07 = 0.04. Cluster 2: 0.03 + 0.01 - 0.02 = 0.02. Cluster 1: 0.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.04. Cluster 0: -0.01 - 0.02 - 0.01 + 0.01 = -0.03.المجموعة 3: -0.03 + 0.12 + 0.02 - 0.07 = 0.04. المجموعة 2: 0.03 + 0.01 - 0.02 = 0.02. المجموعة 1: 0.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.04. المجموعة 0: -0.01 - 0.02 - 0.01 + 0.01 = -0.03.Check the countsتحقق من الأعداد
The groups hold 4 + 3 + 5 + 4 = 16 gradients, one per weight, and the sizes match the clusters of the first concept.المجموعات تضم 4 + 3 + 5 + 4 = 16 gradient، واحدًا لكل وزن، وأحجامها تطابق مجموعات المفهوم الأول.Update with lr = 1حدّث مع lr = 1
2.00 - 0.04 = 1.96, 1.50 - 0.02 = 1.48, 0.00 - 0.04 = -0.04, -1.00 - (-0.03) = -0.97.2.00 - 0.04 = 1.96، 1.50 - 0.02 = 1.48، 0.00 - 0.04 = -0.04، -1.00 - (-0.03) = -0.97.Resultالنتيجة
Fine-tuned codebook 3: 1.96, 2: 1.48, 1: -0.04, 0: -0.97. The index map is unchanged, so every blue weight is now 1.96.دفتر الرموز بعد الضبط: 3: 1.96 و 2: 1.48 و 1: -0.04 و 0: -0.97. خريطة الفهارس لم تتغير، لذلك كل وزن أزرق أصبح الآن 1.96.
| Index (colour)الفهرس (اللون) | Grouped gradientsالـ gradients المجمّعة | Sumالمجموع | New centroidالمركز الجديد |
|---|---|---|---|
| 3 (blue)3 (أزرق) | -0.03 + 0.12 + 0.02 - 0.07-0.03 + 0.12 + 0.02 - 0.07 | 0.040.04 | 2.00 - 0.04 = 1.962.00 - 0.04 = 1.96 |
| 2 (pink)2 (وردي) | 0.03 + 0.01 - 0.020.03 + 0.01 - 0.02 | 0.020.02 | 1.50 - 0.02 = 1.481.50 - 0.02 = 1.48 |
| 1 (orange)1 (برتقالي) | 0.02 - 0.01 + 0.01 + 0.04 - 0.020.02 - 0.01 + 0.01 + 0.04 - 0.02 | 0.040.04 | 0.00 - 0.04 = -0.040.00 - 0.04 = -0.04 |
| 0 (green)0 (أخضر) | -0.01 - 0.02 - 0.01 + 0.01-0.01 - 0.02 - 0.01 + 0.01 | -0.03-0.03 | -1.00 + 0.03 = -0.97-1.00 + 0.03 = -0.97 |
Watch the signs. A positive summed gradient means the loss rises as the centroid rises, so the centroid moves down: blue falls from 2.00 to 1.96. Green's sum is negative, so it moves up, from -1.00 to -0.97. Step through it with a different learning rate below.
انتبه للإشارات. الـ gradient المجموع الموجب يعني أن الخسارة ترتفع عندما يرتفع المركز، لذلك يتحرك المركز إلى الأسفل: الأزرق ينخفض من 2.00 إلى 1.96. مجموع الأخضر سالب، لذلك يتحرك إلى الأعلى، من -1.00 إلى -0.97. جرّب الخطوات بمعدل تعلم مختلف في الأسفل.
- 1. Gradient1. التدرّج
- 2. Group by index2. التجميع حسب الفهرس
- 3. Reduce (sum)3. الاختزال (الجمع)
- 4. Centroid - lr x sum4. المركز - lr x المجموع
- index 3-0.03 + 0.12 + 0.02 - 0.07= 0.042.00 - 1 x 0.04 = 1.96
- index 20.03 + 0.01 - 0.02= 0.021.50 - 1 x 0.02 = 1.48
- index 10.02 - 0.01 + 0.01 + 0.04 - 0.02= 0.040.00 - 1 x 0.04 = -0.04
- index 0-0.01 - 0.02 - 0.01 + 0.01= -0.03-1.00 - 1 x -0.03 = -0.97
Gradients and centroids are the slide 28 and 29 values from Han et al., Figure 3. The slide prints x lr without a value; its fine-tuned centroids only follow with lr = 1. Try lr = 0.1 to see the realistic, much smaller step.التدرّجات والمراكز هي قيم الشريحتين 28 و29 المأخوذة من Han et al.، الشكل 3. تكتب الشريحة x lr دون قيمة، ولا تتحقق مراكزها بعد الضبط الدقيق إلا مع lr = 1. جرّب lr = 0.1 لترى الخطوة الواقعية الأصغر بكثير.
Worked exampleمثال محلول
The same gradients with lr = 0.5نفس الـ gradients مع lr = 0.5
Scale the sumsاضرب المجاميع في معدل التعلم
0.5 × 0.04 = 0.02, 0.5 × 0.02 = 0.01, 0.5 × 0.04 = 0.02, 0.5 × (-0.03) = -0.015.0.5 × 0.04 = 0.02، 0.5 × 0.02 = 0.01، 0.5 × 0.04 = 0.02، 0.5 × (-0.03) = -0.015.Resultالنتيجة
2.00 - 0.02 = 1.98, 1.50 - 0.01 = 1.49, 0.00 - 0.02 = -0.02, -1.00 + 0.015 = -0.985.2.00 - 0.02 = 1.98، 1.50 - 0.01 = 1.49، 0.00 - 0.02 = -0.02، -1.00 + 0.015 = -0.985.
Quick checkاختبار سريع
Centroid 0 is -1.00 and its gradients sum to -0.03. With lr = 0.5, what is the fine-tuned centroid?المركز 0 قيمته -1.00 ومجموع gradients الخاصة به -0.03. مع lr = 0.5، ما قيمة المركز بعد الـ fine-tuning؟
Quick checkاختبار سريع
During centroid fine-tuning, what happens to the 2-bit index matrix?أثناء الـ fine-tuning للمراكز، ماذا يحدث لمصفوفة الفهارس ذات الـ 2 بت؟
Recall
Without looking, reduce the slide 29 gradients for cluster 1 (orange) and give its new centroid at lr = 1.دون أن تنظر، اختزل gradients الشريحة 29 للمجموعة 1 (البرتقالية) وأعطِ مركزها الجديد عند lr = 1.
0.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.04, so 0.00 - 1 × 0.04 = -0.04.
0.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.04، إذن 0.00 - 1 × 0.04 = -0.04.
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- K-means (Lloyd's algorithm) alternates two steps: assign each weight to its nearest centroid, then move each centroid to the mean of its members.خوارزمية K-means (خوارزمية Lloyd) تتناوب بين خطوتين: أسند كل وزن إلى أقرب مركز، ثم انقل كل مركز إلى متوسط أعضائه.
- On the slide example, k = 4 gives centroids -1.00, 0.00, 1.50 and 2.00, each the exact mean of its 4, 5, 3 and 4 weights.في مثال الشريحة، k = 4 يعطي المراكز -1.00 و 0.00 و 1.50 و 2.00، وكل منها هو المتوسط الدقيق لأوزانه البالغ عددها 4 و 5 و 3 و 4 على الترتيب.
- Store an N-bit index per weight plus a codebook of 2^N FP32 centroids. Reconstructed weight = codebook[index].خزّن فهرسًا من N بت لكل وزن، زائد دفتر رموز (codebook) فيه 2^N مركزًا بصيغة FP32. الوزن المُعاد بناؤه = codebook[index].
- Storage: 32M bits before, NM + 32 x 2^N bits after. The example drops 64 B to 4 B + 16 B = 20 B, a 3.2x saving.التخزين: 32M بت قبل، و NM + 32 x 2^N بت بعد. في المثال ينخفض الحجم من 64 B إلى 4 B + 16 B = 20 B، أي توفير بمقدار 3.2x.
- When M is much larger than 2^N the codebook is negligible and the ratio tends to 32/N (8.0x for N = 4 and a million weights).عندما تكون M أكبر بكثير من 2^N يصبح دفتر الرموز مهملًا وتقترب النسبة من 32/N (أي 8.0x عند N = 4 ومليون وزن).
- The index map is frozen during fine-tuning. Only the centroids train, with dL/dC_k = sum of dL/dW over the weights whose index is k.خريطة الفهارس مجمّدة أثناء الـ fine-tuning. المراكز وحدها تتدرّب، مع dL/dC_k = مجموع dL/dW على كل الأوزان التي فهرسها k.
- Slide 29: sums 0.04, 0.02, 0.04, -0.03 give fine-tuned centroids 1.96, 1.48, -0.04, -0.97, which implies lr = 1.الشريحة 29: المجاميع 0.04 و 0.02 و 0.04 و -0.03 تعطي مراكز بعد الضبط 1.96 و 1.48 و -0.04 و -0.97، وهذا يعني أن lr = 1.
Sourcesالمصادر
- Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingPaperS. Han, H. Mao, W. J. Dally, ICLR 2016Section 3 and Figure 3: weight sharing, the compression rate nb / (n log2 k + kb) with the 3.2x example, linear initialisation, Eq. 3 for the centroid gradient, 8-bit conv and 5-bit FC for AlexNet.القسم 3 والشكل 3: مشاركة الأوزان (weight sharing)، ونسبة الضغط nb / (n log2 k + kb) مع مثال 3.2x، والتهيئة الخطية، والمعادلة 3 لـ gradient المركز، و 8 بت لطبقات conv و 5 بت لطبقات FC في AlexNet.(opens in a new tab)(يفتح في تبويب جديد)
- Least Squares Quantization in PCMPaperS. P. Lloyd, IEEE Transactions on Information Theory 28(2), 1982The original quantizer design with a fixed set of representative quanta, the algorithm now called K-means.التصميم الأصلي للمكمِّم (quantizer) بمجموعة ثابتة من القيم الممثِّلة (quanta)، وهي الخوارزمية التي تُسمّى اليوم K-means.(opens in a new tab)(يفتح في تبويب جديد)
- Clustering: K-meansDocsscikit-learn documentationInertia objective, the assign and mean-update steps of Lloyd's algorithm, local minima and initialisation.هدف الـ inertia، وخطوتا الإسناد وتحديث المتوسط في خوارزمية Lloyd، والقيم الصغرى المحلية (local minima)، والتهيئة.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 5: Quantization (Part I)VideoMIT HAN LabCourse page linking the slides and video of the corresponding MIT lecture on quantization.صفحة المقرر التي تربط بشرائح وفيديو محاضرة MIT المقابلة عن التكميم (quantization).(opens in a new tab)(يفتح في تبويب جديد)