COE 592Lecture 01المحاضرة 01Part 01الجزء 01
Accuracy comes at a costالدقة لها ثمن
Deep learning now beats humans on ImageNet, but every accuracy gain was paid for in computation and model size, and efficient design (NAS, MCUNet, on-device training) is what brings it to phones and IoT devices.تتفوق نماذج التعلم العميق اليوم على البشر في ImageNet، لكن كل زيادة في الدقة دُفع ثمنها حسابًا وحجمًا للنموذج، والتصميم الكفء (NAS وMCUNet والتدريب على الجهاز) هو ما يوصلها إلى الهواتف وأجهزة إنترنت الأشياء (IoT).
- Conceptsالمفاهيم
- 6
- Slidesالشرائح
- 1-8
- Readingمدة القراءة
- 36 min36 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
Every later part of this lecture, from segmentation and diffusion models to LiDAR, language models, accelerators and microcontrollers, is a response to one trade-off introduced here: accuracy is bought with computation and memory, and the devices you want to deploy on cannot pay the bill.
This part builds that trade-off from the ground up. You will learn to read the two charts that anchor the whole course (top-5 error over the ImageNet years, then top-1 accuracy against MACs and parameters), to compute the reduction ratios that headline efficient-model papers, and to argue why efficiency matters for privacy, cost and connectivity and not only for speed. The exam asks exactly these things, and your own embedded ML research lives on the frontier the last two concepts describe.
كل جزء لاحق في هذه المحاضرة، من نماذج التقسيم (segmentation) ونماذج الانتشار (diffusion) إلى LiDAR ونماذج اللغة والمسرّعات والمتحكمات الدقيقة، هو استجابة لمقايضة واحدة نقدمها هنا: الدقة تُشترى بالحوسبة والذاكرة، والأجهزة التي تريد النشر عليها لا تستطيع دفع هذه الفاتورة.
يبني هذا الجزء تلك المقايضة من الأساس. ستتعلم قراءة المخططين اللذين يرتكز عليهما المقرر كله (خطأ top-5 عبر سنوات ImageNet، ثم دقة top-1 مقابل MACs وعدد المعاملات)، وحساب نسب التقليل التي تتصدر عناوين أوراق النماذج الكفؤة، والدفاع عن أهمية الكفاءة للخصوصية والتكلفة والاتصال وليس للسرعة فقط. الامتحان يسأل عن هذه الأشياء بالضبط، وبحثك أنت في تعلم الآلة المدمج يقع على الحدّ الذي يصفه المفهومان الأخيران.
By the end you canفي نهاية هذا الجزء ستستطيع
- State the course challenge and name the three pillars, with one efficiency lever per pillar.تذكر تحدي المقرر وتسمّي الركائز الثلاث، مع أداة واحدة لتحسين الكفاءة في كل ركيزة.
- Define top-5 error and top-1 accuracy precisely and explain why they cannot be compared directly.تعرّف خطأ top-5 ودقة top-1 تعريفًا دقيقًا، وتشرح لماذا لا يمكن مقارنتهما مباشرة.
- Read a bubble chart of top-1 accuracy versus MACs and parameters, and quantify diminishing returns.تقرأ مخطط الفقاعات لدقة top-1 مقابل MACs وعدد المعاملات، وتقيس تناقص العائد بالأرقام.
- Compute a computation reduction ratio and explain the Pareto frontier shift produced by architecture search.تحسب نسبة تقليل الحوسبة، وتشرح انزياح حدّ باريتو (Pareto frontier) الذي ينتجه البحث عن المعماريات.
- Explain why TinyML and on-device training are hard, using the memory tiers and the cost of backpropagation.تشرح لماذا يصعب TinyML والتدريب على الجهاز، مستخدمًا مستويات الذاكرة وتكلفة الانتشار العكسي (backpropagation).
Open the camera on your phone and it finds faces before you press anything. Ask a speaker a question and a language model answers. Paste a screenshot into a chatbot and it reads the text and the picture together. Vision, language and multimodal tasks are all served today by deep networks, and every one of those answers costs billions of arithmetic operations. Classifying a single image with ResNet-50 takes about 3.9 billion multiply-accumulate operations (Sze et al., 2017), and that is a model from 2015 doing the easiest of the three tasks.
افتح كاميرا هاتفك وستجد أنها تكتشف الوجوه قبل أن تضغط أي زر. اسأل مكبّر صوت ذكيًا سؤالًا فيجيبك نموذج لغة. الصق لقطة شاشة في روبوت محادثة فيقرأ النص والصورة معًا. مهام الرؤية واللغة والمهام متعددة الوسائط تخدمها اليوم كلها الشبكات العميقة، وكل إجابة من هذه الإجابات تكلّف مليارات العمليات الحسابية. تصنيف صورة واحدة بـ ResNet-50 يحتاج نحو 3.9 billion عملية ضرب وجمع تراكمي (multiply-accumulate) (Sze et al., 2017)، وهذا نموذج من عام 2015 يؤدي أسهل المهام الثلاث.
That is the whole tension of this course, and slide 2 states it in one line. Machine learning (ML) and deep learning are applied everywhere, they are computationally expensive, and the challenge is to make them lightweight and fast without losing accuracy. Every technique you will learn, from pruning and quantization to architecture search, hardware accelerators and tiny Inference engines, is one answer to that single question. It helps to write the question the way an optimization course would: keep accuracy as high as possible while staying under whatever budget the target device imposes.
هذا هو التوتر الأساسي في المقرر كله، والشريحة 2 تلخصه في سطر واحد. Machine learning (ML) والتعلم العميق يُطبَّقان في كل مكان، وهما مكلفان حسابيًا، والتحدي هو جعلهما خفيفين وسريعين دون خسارة الدقة. كل تقنية ستتعلمها، من التقليم (pruning) والتكميم (quantization) إلى البحث عن المعماريات والمسرّعات العتادية ومحركات Inference الصغيرة، هي إجابة واحدة عن هذا السؤال الوحيد. ومن المفيد أن نكتب السؤال بالطريقة التي يكتبه بها مقرر في التحسين الرياضي (optimization): أبقِ الدقة أعلى ما يمكن مع البقاء تحت أي ميزانية يفرضها الجهاز المستهدف.
The budgets are what change from device to device. A cloud GPU has a generous C and M; a phone has a tight Latency T and a battery; a sensor node has a memory M measured in kilobytes. The accuracy you can afford depends on which row of that constraint list binds, and part 03 puts real numbers on each row.
الميزانيات هي ما يتغير من جهاز إلى آخر. وحدة GPU سحابية لديها C وM سخيّان، والهاتف لديه قيد صارم على Latency T وبطارية، وعقدة الاستشعار لديها ذاكرة M تقاس بالكيلوبايت. الدقة التي تستطيع تحمّلها تعتمد على أي سطر من قائمة القيود هذه هو الذي يقيّدك فعلًا، والجزء 03 يضع أرقامًا حقيقية لكل سطر.
Three pillars, one lens for the whole courseثلاث ركائز، عدسة واحدة للمقرر كله
Slide 3 gives you the lens to organize everything that follows: deep learning advances when three things improve together. Its three pillars are the algorithm (the model and how it is trained), the hardware it runs on, and the data it learns from. None of them is enough alone. The 2012 breakthrough on ImageNet, which the next concept quantifies, needed all three at once: a new deep convolutional architecture, two GPUs able to run it for a week, and a dataset of about 1.2 million labeled images (Krizhevsky et al., 2012).
تعطيك الشريحة 3 العدسة التي تنظّم بها كل ما يأتي: يتقدم التعلم العميق عندما تتحسن ثلاثة أشياء معًا. الركائز الثلاث هي الخوارزمية (النموذج وطريقة تدريبه)، والعتاد الذي يعمل عليه، والبيانات التي يتعلم منها. لا تكفي أي منها وحدها. اختراق عام 2012 على ImageNet، الذي يقيسه المفهوم التالي بالأرقام، احتاج الثلاث في آن واحد: معمارية التفافية عميقة جديدة، ووحدتي GPU قادرتين على تشغيلها لمدة أسبوع، ومجموعة بيانات من نحو 1.2 million صورة موسومة (Krizhevsky et al., 2012).
| Pillarالركيزة | Contribution to AlexNet in 2012إسهامها في AlexNet عام 2012 | Efficiency lever in this courseأداة الكفاءة في هذا المقرر |
|---|---|---|
| Algorithmالخوارزمية | A deep CNN with ReLU units and dropout, trained with SGD on two GPUsشبكة CNN عميقة بوحدات ReLU وأسلوب dropout، دُرِّبت بـ SGD على وحدتي GPU | Pruning, quantization, distillation, neural architecture search (pruning starts in lecture 04)التقليم والتكميم والتقطير والبحث عن المعمارية العصبية (يبدأ التقليم في المحاضرة 04) |
| Hardwareالعتاد | Two GTX 580 GPUs, 3 GB each, running the convolutions for about six daysوحدتا GTX 580، في كل منهما 3 GB، تشغّلان الالتفافات لمدة ستة أيام تقريبًا | Accelerators from cloud GPUs to phone NPUs and microcontrollers (part 03)المسرّعات، من وحدات GPU السحابية إلى وحدات NPU في الهواتف والمتحكمات الدقيقة (الجزء 03) |
| Dataالبيانات | ImageNet: about 1.2 million labeled training images in 1000 classesImageNet: نحو 1.2 million صورة تدريب موسومة في 1000 صنف | Data that stays on the device and drives local, private learning (slide 8)بيانات تبقى على الجهاز وتقود تعلمًا محليًا يحفظ الخصوصية (الشريحة 8) |
The same three words tell you where efficiency work happens. Compressing, quantizing and searching for architectures are algorithm-pillar work: the model changes, the chip does not. Building accelerators, from data-center GPUs down to the Hexagon DSP and the Neural Engine, is hardware-pillar work: the chip changes so that the same model runs faster or cooler. The deck returns to this exact slide as slide 17 to open the hardware section, so treat slide 3 as the introduction of the framework and slide 17 as the pivot to its second pillar. The data pillar makes its own appearance on slide 8, where data that cannot leave a device forces learning to happen on the device.
الكلمات الثلاث نفسها تخبرك أين يحدث عمل الكفاءة. الضغط والتكميم والبحث عن المعماريات عمل في ركيزة الخوارزمية: النموذج يتغير والشريحة لا تتغير. بناء المسرّعات، من وحدات GPU في مراكز البيانات نزولًا إلى Hexagon DSP وNeural Engine، عمل في ركيزة العتاد: الشريحة تتغير كي يعمل النموذج نفسه أسرع أو بحرارة أقل. تعود المحاضرة إلى هذه الشريحة نفسها بوصفها الشريحة 17 لتفتتح قسم العتاد، فاعتبر الشريحة 3 مقدمة الإطار والشريحة 17 نقطة الانتقال إلى ركيزته الثانية. أما ركيزة البيانات فتظهر بنفسها في الشريحة 8، حيث تجبر البيانات التي لا يمكنها مغادرة الجهاز التعلمَ على أن يحدث على الجهاز.
Why efficiency matters beyond speedلماذا تهم الكفاءة لما هو أبعد من السرعة
Speed is the obvious reason to want small models, but the exam will ask for more, and the deck gives you at least four. Privacy: a model that fits on the device can process a face or a voice without uploading it. Cost: training and serving large models is billed in GPU hours and, increasingly, in carbon. The Once-for-All paper notes that training a separate specialized network for every deployment target emits as much CO2 as five cars over their lifetimes (Cai et al., 2020). Connectivity: sensors in fields, mines and rural clinics may have no network at all, and MCUNet argues that on-device processing extends AI to areas without Internet access (Lin et al., 2020). Energy: a battery-powered node has a milliwatt budget, and every unnecessary multiply drains it.
السرعة هي السبب الواضح لطلب نماذج صغيرة، لكن الامتحان سيطلب أكثر، والمحاضرة تعطيك أربعة أسباب على الأقل. الخصوصية: النموذج الذي يتسع في الجهاز يستطيع معالجة وجه أو صوت دون رفعه. التكلفة: تدريب النماذج الكبيرة وتشغيلها يُحاسَب بساعات GPU، وبالكربون بشكل متزايد. تذكر ورقة Once-for-All أن تدريب شبكة متخصصة منفصلة لكل هدف نشر يطلق من CO2 ما تطلقه خمس سيارات طوال عمرها (Cai et al., 2020). الاتصال: أجهزة الاستشعار في الحقول والمناجم والعيادات الريفية قد لا يكون لديها أي شبكة، ويحتج MCUNet بأن المعالجة على الجهاز توصل الذكاء الاصطناعي إلى المناطق التي لا يتوفر فيها الإنترنت (Lin et al., 2020). الطاقة: العقدة التي تعمل بالبطارية لديها ميزانية بالمللي واط، وكل عملية ضرب غير ضرورية تستنزفها.
- Privacy: raw data stays where it was collected.الخصوصية: البيانات الخام تبقى حيث جُمعت.
- Cost: fewer GPU hours, smaller cloud bills, less carbon.التكلفة: ساعات GPU أقل، وفواتير سحابية أصغر، وكربون أقل.
- Connectivity: the model works where the network does not.الاتصال: النموذج يعمل حيث لا تعمل الشبكة.
- Energy: milliwatt devices need models sized for milliwatts.الطاقة: الأجهزة التي تعمل بالمللي واط تحتاج نماذج على مقاس المللي واط.
Recall
State the three pillars and name one efficiency lever for each.اذكر الركائز الثلاث وسمِّ أداة كفاءة واحدة لكل منها.
Look at the left panel of slide 4 before the bar chart. It shows six test images (a crop of the eight in the AlexNet paper) with the five classes AlexNet ranked highest for each. For the mushroom photo the top guess is "agaric" and the true label "mushroom" sits second. For the cherry photo the top guess is "dalmatian", followed by grape, elderberry, a bull terrier and currant; "cherry" is nowhere in the list. Under one scoring rule the mushroom counts as correct and the cherry does not; under another rule both are wrong. Which rule you use decides every number on the right of the slide.
انظر إلى اللوحة اليسرى من الشريحة 4 قبل المخطط العمودي. تعرض ست صور اختبار (مقتطعة من الثماني الموجودة في ورقة AlexNet) ومع كل منها الأصناف الخمسة التي رتّبها AlexNet في الأعلى. في صورة الفطر يكون التخمين الأول "agaric" ويأتي الوسم الصحيح "mushroom" في المرتبة الثانية. في صورة الكرز يكون التخمين الأول "dalmatian"، يليه grape وelderberry وbull terrier وcurrant، ولا يظهر "cherry" في القائمة أبدًا. وفق قاعدة تقييم معينة تُحسب صورة الفطر صحيحة وصورة الكرز خاطئة، ووفق قاعدة أخرى تكون الاثنتان خاطئتين. القاعدة التي تستخدمها هي التي تحدد كل رقم على يمين الشريحة.
The rule the contest used is Top-5 error rate. The ImageNet challenge (ILSVRC) let each algorithm return five labels per image and counted the image as correct if any one of them matched the single ground-truth label; the error is the fraction of test images with no match (Russakovsky et al., 2015, Eq. 1). The organizers allowed five guesses because ImageNet photos often contain several objects but carry only one label, and a system that names a visible second object should not be punished. From 2012 the contest reported only top-5 error, since all their measures ranked entries the same way.
القاعدة التي استخدمتها المسابقة هي Top-5 error rate. سمحت مسابقة ImageNet (ILSVRC) لكل خوارزمية بأن تعيد خمسة وسوم لكل صورة، وعدّت الصورة صحيحة إذا طابق أيٌّ منها الوسم الحقيقي الوحيد، والخطأ هو نسبة صور الاختبار التي لا يوجد لها أي تطابق (Russakovsky et al., 2015, Eq. 1). سمح المنظمون بخمسة تخمينات لأن صور ImageNet تحتوي غالبًا على عدة أجسام لكنها تحمل وسمًا واحدًا فقط، والنظام الذي يسمّي جسمًا ثانيًا ظاهرًا في الصورة لا ينبغي أن يُعاقَب. ومنذ عام 2012 لم تعد المسابقة تعلن إلا خطأ top-5، لأن كل مقاييسها كانت ترتب المشاركات بالترتيب نفسه.
The other rule, Top-1 accuracy, keeps only the single highest-scoring class and counts the fraction of images where it matches. It is stricter, so the same model always scores worse on top-1 than on top-5. Slides 5 and 6 use top-1 accuracy; slide 4 uses top-5 error. Keeping the two apart is the single most common slip in reading this part of the deck.
القاعدة الأخرى، Top-1 accuracy، تحتفظ فقط بالصنف صاحب أعلى درجة، وتحسب نسبة الصور التي يطابق فيها الوسم الصحيح. هي أشد صرامة، ولذلك يحصل النموذج نفسه دائمًا على نتيجة أسوأ في top-1 منها في top-5. الشريحتان 5 و6 تستخدمان دقة top-1، والشريحة 4 تستخدم خطأ top-5. الفصل بين الاثنين هو أهم ما يجب الانتباه له، فالخلط بينهما أكثر زلة شيوعًا عند قراءة هذا الجزء من الشرائح.
The same AlexNet predictions under both rulesتنبؤات AlexNet نفسها وفق القاعدتين
- Mushroom (top guess agaric, mushroom second)الفطر (التخمين الأول agaric، وmushroom في المرتبة الثانية)
- Top-5 hit, top-1 missإصابة في top-5، وإخفاق في top-1
- Cherry (top guess dalmatian, cherry absent)الكرز (التخمين الأول dalmatian، وcherry غائب)
- Top-5 miss, top-1 missإخفاق في top-5، وإخفاق في top-1
- Container ship (top guess container ship)سفينة الحاويات (التخمين الأول container ship)
- Top-5 hit, top-1 hitإصابة في top-5، وإصابة في top-1
Eight years of the winning entryثماني سنوات من المشاركة الفائزة
With the metric fixed, the bar chart reads as a history. The winning top-5 error went from 28.2% in 2010 and 25.8% in 2011 to 16.4% in 2012, when SuperVision, the entry now called AlexNet, was the first deep convolutional network to win. The error kept falling as the networks deepened: Clarifai at 11.7% in 2013, GoogLeNet at 6.7% in 2014, ResNet at 3.57% in 2015 with an ensemble of residual networks up to 152 layers deep (He et al., 2016), Trimps-Soushen at 2.99% in 2016 and SENet at 2.25% in 2017 (Hu et al., 2018). The slide rounds those to one decimal.
بعد تثبيت المقياس يُقرأ المخطط العمودي كتاريخ. انتقل خطأ top-5 الفائز من 28.2% في 2010 و25.8% في 2011 إلى 16.4% في 2012، عندما كانت SuperVision، المشاركة التي تسمى الآن AlexNet، أول شبكة التفافية عميقة تفوز. واستمر الخطأ في الانخفاض مع ازدياد عمق الشبكات: Clarifai بنسبة 11.7% في 2013، وGoogLeNet بنسبة 6.7% في 2014، وResNet بنسبة 3.57% في 2015 بمجموعة (ensemble) من الشبكات المتبقية (residual) يصل عمقها إلى 152 طبقة (He et al., 2016)، وTrimps-Soushen بنسبة 2.99% في 2016، وSENet بنسبة 2.25% في 2017 (Hu et al., 2018). الشريحة تقرّب هذه القيم إلى منزلة عشرية واحدة.
| Yearالسنة | Winnerالفائز | Top-5 error (%)خطأ top-5 (%) | Sourceالمصدر |
|---|---|---|---|
| 20102010 | NECNEC | 28.228.2 | Russakovsky et al., Table 5Russakovsky et al.، الجدول 5 |
| 20112011 | XRCEXRCE | 25.825.8 | Russakovsky et al., Table 5Russakovsky et al.، الجدول 5 |
| 20122012 | SuperVision (AlexNet)SuperVision (AlexNet) | 16.416.4 | Russakovsky et al., Table 5Russakovsky et al.، الجدول 5 |
| 20132013 | ClarifaiClarifai | 11.711.7 | Russakovsky et al., Table 6Russakovsky et al.، الجدول 6 |
| 20142014 | GoogLeNetGoogLeNet | 6.76.7 | Russakovsky et al., Table 7Russakovsky et al.، الجدول 7 |
| 20152015 | ResNet (ensemble of six models, deepest 152 layers)ResNet (مجموعة من ست نماذج، أعمقها 152 طبقة) | 3.6 (3.57)3.6 (3.57) | He et al., 2016He et al., 2016 |
| 20162016 | Trimps-SoushenTrimps-Soushen | 3.0 (2.99)3.0 (2.99) | ILSVRC 2016 resultsنتائج ILSVRC 2016 |
| 20172017 | SENet (WMW)SENet (WMW) | 2.3 (2.25)2.3 (2.25) | Hu et al., 2018Hu et al., 2018 |
| Humanالإنسان | One trained annotatorمُوسِّم واحد مدرَّب | 5.15.1 | Russakovsky et al., Sec. 6.4Russakovsky et al.، القسم 6.4 |
Worked exampleمثال محلول
Reading the dropقراءة الانخفاض
The deep learning breakاختراق التعلم العميق
2011 to 2012: 25.8 - 16.4 = 9.4 percentage points, a relative reduction of 9.4 / 25.8 = 36% in one year, after the previous year had removed only 2.4 points.من 2011 إلى 2012: 25.8 - 16.4 = 9.4 نقطة مئوية، أي انخفاض نسبي قدره 9.4 / 25.8 = 36% في سنة واحدة، بعد أن أزالت السنة السابقة 2.4 نقطة فقط.Two more years of depthسنتان أخريان من العمق
2012 to 2014: 16.4 / 6.7 = 2.45x lower error with GoogLeNet, a 22-layer network (Szegedy et al., 2015).من 2012 إلى 2014: خطأ أقل بـ 16.4 / 6.7 = 2.45x مع GoogLeNet، وهي شبكة من 22 طبقة (Szegedy et al., 2015).Crossing the human lineعبور الخط البشري
ResNet's 3.57% in 2015 is the first winning entry below the 5.1% human estimate, and by 2017 the gap is 5.1 - 2.25 = 2.85 points in the machine's favor.نسبة 3.57% التي حققها ResNet في 2015 هي أول مشاركة فائزة تقل عن التقدير البشري البالغ 5.1%، وبحلول 2017 صارت الفجوة 5.1 - 2.25 = 2.85 نقطة لصالح الآلة.Resultالنتيجة
Over eight years the winning error fell from 28.2% to 2.3%, about 12x lower, and nearly all of it came after the switch to deep networks.على مدى ثماني سنوات انخفض الخطأ الفائز من 28.2% إلى 2.3%، أي أقل بنحو 12x، وجاء كله تقريبًا بعد التحول إلى الشبكات العميقة.
What "super-human" actually means hereماذا يعني "أفضل من البشر" هنا فعلًا
The human bar is not an average person. It is one expert annotator who trained on 500 images and then labeled 1500 test images at roughly one per minute, reaching 5.1% top-5 error; a second annotator with less training scored 12.0%, and GoogLeNet scored 6.8% on the same sample (Russakovsky et al., 2015, Sec. 6.4). So "DNNs achieve super-human accuracy" means that from 2015 the winning network beats a well-trained, patient human on the top-5 rule for 1000 fine-grained classes, many of them dog breeds. It says nothing about general vision, and it says nothing about top-1.
العمود البشري لا يمثل شخصًا عاديًا. إنه مُوسِّم خبير واحد تدرّب على 500 صورة ثم وسم 1500 صورة اختبار بمعدل صورة في الدقيقة تقريبًا، فوصل إلى خطأ top-5 قدره 5.1%. ومُوسِّم ثانٍ بتدريب أقل حصل على 12.0%، وحصل GoogLeNet على 6.8% على العينة نفسها (Russakovsky et al., 2015, Sec. 6.4). إذن عبارة "DNNs achieve super-human accuracy" تعني أن الشبكة الفائزة منذ 2015 تتفوق على إنسان مدرَّب جيدًا وصبور وفق قاعدة top-5 على 1000 صنف دقيق التفاصيل، كثير منها سلالات كلاب. ولا تقول شيئًا عن الرؤية العامة، ولا تقول شيئًا عن top-1.
Quick checkاختبار سريع
In ILSVRC top-5 evaluation, when does one image count as correctly classified?في تقييم top-5 لمسابقة ILSVRC، متى تُحسب الصورة الواحدة مصنفة تصنيفًا صحيحًا؟
Recall
Define top-5 error precisely. Is the mushroom image, with top guess agaric and mushroom second, a top-5 hit? Is the cherry image?عرّف خطأ top-5 بدقة. هل صورة الفطر، التي تخمينها الأول agaric وmushroom في المرتبة الثانية، إصابة في top-5؟ وماذا عن صورة الكرز؟
Take two models from the same family. ResNet-50 needs about 3.8 billion multiply-adds per image and ResNet-101 about 7.6 billion, twice as many (He et al., 2016, Table 1). On slide 5 they sit at about 75.3% and 76.4% top-1 accuracy. Doubling the work bought about one percentage point. That one pair is the message of the slide: high accuracy comes at the cost of high computation, and the exchange rate gets worse as you climb.
خذ نموذجين من العائلة نفسها. يحتاج ResNet-50 نحو 3.8 billion عملية ضرب وجمع لكل صورة، وResNet-101 نحو 7.6 billion، أي الضعف (He et al., 2016, Table 1). في الشريحة 5 يقعان عند دقة top-1 تقارب 75.3% و76.4%. مضاعفة العمل اشترت نحو نقطة مئوية واحدة. هذا الزوج وحده هو رسالة الشريحة: الدقة العالية تأتي على حساب حوسبة عالية، وسعر الصرف يسوء كلما صعدت.
To read the chart you need its currency. The horizontal axis counts MACs, multiply-accumulate operations: one multiplication of an input by a weight, immediately added into a running sum. Sze and colleagues call the MAC "the fundamental component" of both convolutional and fully connected layers (Sze et al., 2017). Counting MACs gives a hardware-neutral cost: the number is a property of the model and the input size, not of the chip, unlike latency or energy which change with every device. A convolutional layer's count follows directly from its shape.
لكي تقرأ المخطط تحتاج إلى عملته. المحور الأفقي يعدّ MACs، أي عمليات الضرب والجمع التراكمي: ضرب مدخل واحد في وزن، ثم إضافة الناتج فورًا إلى مجموع جارٍ. يسمي Sze وزملاؤه عملية MAC "المكوّن الأساسي" (the fundamental component) للطبقات الالتفافية والطبقات المتصلة بالكامل معًا (Sze et al., 2017). عدّ MACs يعطي تكلفة مستقلة عن العتاد: الرقم خاصية للنموذج وحجم المدخل، لا للشريحة، بخلاف زمن الاستجابة أو الطاقة اللذين يتغيران مع كل جهاز. وعدد عمليات الطبقة الالتفافية ينتج مباشرة من أبعادها.
Worked exampleمثال محلول
One 3 by 3 layerطبقة واحدة بحجم 3 في 3
Shapeالأبعاد
A 3 x 3 convolution with 64 input and 64 output channels producing a 56 x 56 map.طبقة التفاف 3 x 3 بـ 64 قناة دخل و64 قناة خرج تنتج خريطة بحجم 56 x 56.Multiply outاضرب الأبعاد
56 x 56 x 64 x 64 x 9 = 115,605,504 MACs.56 x 56 x 64 x 64 x 9 = 115,605,504 عملية MAC.Resultالنتيجة
About 0.116 GMACs for a single layer. ResNet-50 has dozens of such layers, which is how it reaches 3.9 GMACs per image.نحو 0.116 GMACs لطبقة واحدة فقط. ويحتوي ResNet-50 على عشرات الطبقات المشابهة، وهكذا يصل إلى 3.9 GMACs لكل صورة.
How to read a bubble chartكيف تقرأ مخطط الفقاعات
Three quantities share the chart. Horizontal position is cost in billions of MACs, so left is cheaper. Vertical position is Top-1 accuracy on ImageNet, so up is better. Bubble area is Model size, the number of parameters, from 2 M to 64 M according to the legend. Parameters measure storage (how many bytes the weights occupy) and MACs measure work (how many operations each input triggers), and the two are related but not the same. Circles are handcrafted architectures and stars are found by AutoML, which becomes important on the next slide. The goal region is the upper left: high accuracy at low cost.
ثلاث كميات تتشارك المخطط. الموضع الأفقي هو التكلفة بمليارات MACs، فاليسار أرخص. الموضع العمودي هو Top-1 accuracy على ImageNet، فالأعلى أفضل. ومساحة الفقاعة هي Model size، أي عدد المعاملات، من 2 M إلى 64 M وفق مفتاح الرسم. عدد المعاملات يقيس التخزين (كم بايتًا تشغل الأوزان)، وMACs تقيس العمل (كم عملية يطلقها كل مدخل)، والاثنان مرتبطان لكنهما ليسا الشيء نفسه. الدوائر معماريات مصممة يدويًا، والنجوم وجدها AutoML، وهذا يصبح مهمًا في الشريحة التالية. المنطقة المطلوبة هي الزاوية العليا اليسرى: دقة عالية بتكلفة منخفضة.
| Modelالنموذج | MACs (B)MACs (B) | Top-1 (%)Top-1 (%) | Parametersالمعاملات | Where the number comes fromمصدر الرقم |
|---|---|---|---|---|
| MobileNetV1MobileNetV1 | 0.570.57 | 70.670.6 | 4.2 M4.2 M | paper (Howard et al.)الورقة (Howard et al.) |
| IGCV3-DIGCV3-D | 0.30.3 | 72.372.3 | about 3.5 Mنحو 3.5 M | chartالمخطط |
| InceptionV2InceptionV2 | 2.02.0 | 74.874.8 | about 11 Mنحو 11 M | chartالمخطط |
| DenseNet-121DenseNet-121 | 2.92.9 | 75.075.0 | about 8 Mنحو 8 M | chartالمخطط |
| DenseNet-169DenseNet-169 | 3.43.4 | 76.276.2 | about 14 Mنحو 14 M | chartالمخطط |
| ResNet-50ResNet-50 | 3.93.9 | 75.375.3 | 25.5 M25.5 M | MACs and params from Sze et al., accuracy from the chartMACs والمعاملات من Sze et al.، والدقة من المخطط |
| ResNeXt-50ResNeXt-50 | 4.24.2 | 77.877.8 | about 25 Mنحو 25 M | chartالمخطط |
| DenseNet-264DenseNet-264 | 5.75.7 | 77.877.8 | about 33 Mنحو 33 M | chartالمخطط |
| InceptionV3InceptionV3 | 5.75.7 | 78.878.8 | about 24 Mنحو 24 M | chartالمخطط |
| DPN-92DPN-92 | 6.56.5 | 79.379.3 | about 38 Mنحو 38 M | chartالمخطط |
| ResNet-101ResNet-101 | 7.67.6 | 76.476.4 | 44.5 M44.5 M | MACs from He et al. (Table 1); parameters from torchvisionMACs من He et al. (الجدول 1)، والمعاملات من torchvision |
| ResNeXt-101ResNeXt-101 | 8.08.0 | 78.978.9 | about 44 Mنحو 44 M | chartالمخطط |
| XceptionXception | 8.48.4 | 79.079.0 | about 23 Mنحو 23 M | params from Cholletالمعاملات من Chollet |
Diminishing returnsتناقص العائد
Trace the chart from the cheapest model upward and the exchange rate collapses. For each step, divide the accuracy gained by the extra MACs spent. MobileNetV1 is the cheap starting point at 70.6% for 0.57 B MACs (Howard et al., 2017); every other number below is read from the chart.
تتبّع المخطط من أرخص نموذج صعودًا وستجد أن سعر الصرف ينهار. في كل خطوة، اقسم الدقة المكتسبة على MACs الإضافية المنفقة. MobileNetV1 هو نقطة البداية الرخيصة عند 70.6% مقابل 0.57 B MACs (Howard et al., 2017)، وكل رقم آخر أدناه مقروء من المخطط.
| Upgradeالترقية | Extra MACs (B)MACs إضافية (B) | Extra top-1 (points)زيادة top-1 (نقاط) | Points per billion MACsالنقاط لكل مليار MACs |
|---|---|---|---|
| MobileNetV1 to ResNet-50من MobileNetV1 إلى ResNet-50 | 3.9 - 0.57 = 3.333.9 - 0.57 = 3.33 | 75.3 - 70.6 = 4.775.3 - 70.6 = 4.7 | 4.7 / 3.33 = 1.414.7 / 3.33 = 1.41 |
| ResNet-50 to Xceptionمن ResNet-50 إلى Xception | 8.4 - 3.9 = 4.58.4 - 3.9 = 4.5 | 79.0 - 75.3 = 3.779.0 - 75.3 = 3.7 | 3.7 / 4.5 = 0.823.7 / 4.5 = 0.82 |
| ResNet-50 to ResNet-101من ResNet-50 إلى ResNet-101 | 7.6 - 3.9 = 3.77.6 - 3.9 = 3.7 | 76.4 - 75.3 = 1.176.4 - 75.3 = 1.1 | 1.1 / 3.7 = 0.301.1 / 3.7 = 0.30 |
The marginal value of computation falls almost fivefold across the chart, from 1.41 to 0.30 points per billion, and the worst trade is inside a single family. Notice also that Xception is itself dominated: DPN-92 is more accurate (79.3%) with fewer MACs (6.5 B).
تنخفض القيمة الحدّية للحوسبة نحو خمسة أضعاف عبر المخطط، من 1.41 إلى 0.30 نقطة لكل مليار، وأسوأ صفقة تقع داخل عائلة واحدة. ولاحظ أيضًا أن Xception نفسه مُهيمَن عليه (dominated): DPN-92 أدق منه (79.3%) وبعدد أقل من MACs (6.5 B).
Quick checkاختبار سريع
On slide 5, which quantity does the area of each bubble encode?في الشريحة 5، ما الكمية التي تمثلها مساحة كل فقاعة؟
Now put the stars back on the chart. Once-for-All (OFA) reaches 80.0% top-1 with 595 M MACs (Cai et al., 2020). Xception, the most expensive handcrafted model on the previous slide and within 0.3 points of the most accurate (DPN-92), needed about 8.4 B for 79.0%. Divide and you get 8400 / 595 = 14.1: the same accuracy, or one point more, for one fourteenth of the computation. That is the dashed arrow at the top of slide 6, and it is drawn straight from Figure 2 of the Once-for-All paper.
الآن أعد النجوم إلى المخطط. يصل Once-for-All (OFA) إلى دقة top-1 تبلغ 80.0% بـ 595 M MACs (Cai et al., 2020). أما Xception، أغلى نموذج مصمم يدويًا في الشريحة السابقة والذي يبعد 0.3 نقطة فقط عن الأدق (DPN-92)، فقد احتاج نحو 8.4 B للوصول إلى 79.0%. اقسم فتحصل على 8400 / 595 = 14.1: الدقة نفسها، أو نقطة أكثر، مقابل جزء من أربعة عشر من الحوسبة. هذا هو السهم المتقطع في أعلى الشريحة 6، وهو مرسوم مباشرة من الشكل 2 في ورقة Once-for-All.
Worked exampleمثال محلول
Reduction ratiosنسب التقليل
Convert to one unitحوّل إلى وحدة واحدة
Xception 8.4 B = 8400 M MACs; ResNet-50 3.9 B = 3900 M; Once-for-All 595 M.Xception: 8.4 B = 8400 M MACs، وResNet-50: 3.9 B = 3900 M، وOnce-for-All: 595 M.Divide reference by newاقسم المرجع على الجديد
8400 / 595 = 14.1 and 3900 / 595 = 6.6.8400 / 595 = 14.1 و3900 / 595 = 6.6.Resultالنتيجة
Once-for-All needs 14x less computation than Xception and 6.6x less than ResNet-50 while being more accurate than both.يحتاج Once-for-All إلى حوسبة أقل بـ 14x من Xception وأقل بـ 6.6x من ResNet-50، وهو مع ذلك أدق من الاثنين.
| Modelالنموذج | MACs (B)MACs (B) | Top-1 (%)Top-1 (%) | Reduction relative to OFAالتقليل نسبةً إلى OFA |
|---|---|---|---|
| MobileNetV1MobileNetV1 | 0.5690.569 | 70.670.6 | 0.96x (about the same budget)0.96x (الميزانية نفسها تقريبًا) |
| ResNet-50ResNet-50 | 3.93.9 | 75.375.3 | 6.6x6.6x |
| XceptionXception | 8.48.4 | 79.079.0 | 14.1x14.1x |
| Once-for-AllOnce-for-All | 0.5950.595 | 80.080.0 | 1x (reference)1x (المرجع) |
The MobileNetV1 row makes the point from the other side: at essentially the same budget, the searched model is 9.4 points more accurate. The stars are all products of Neural architecture search (NAS): rather than a person choosing kernel sizes, widths and depths, an algorithm searches over them under an explicit MAC or latency budget. EfficientNet, NASNet-A, MobileNetV3, ProxylessNAS, AmoebaNet, PNASNet and DARTS all sit inside the boxed region below about 2.5 B MACs, next to two efficient handcrafted models, MobileNetV2 and ShuffleNet. Once-for-All adds one more idea: train a single large network once, then cut specialized sub-networks out of it for each device, which is what makes the 80.0% at 595 M affordable to produce as well as to run.
صف MobileNetV1 يوضح الفكرة من الجهة الأخرى: عند الميزانية نفسها تقريبًا، النموذج الناتج عن البحث أدق بـ 9.4 نقطة. النجوم كلها نتاج Neural architecture search (NAS): بدلًا من أن يختار شخصٌ أحجام النوى والعرض والعمق، تبحث خوارزمية فيها تحت ميزانية صريحة من MACs أو زمن الاستجابة. EfficientNet وNASNet-A وMobileNetV3 وProxylessNAS وAmoebaNet وPNASNet وDARTS كلها تقع داخل المنطقة المحاطة بإطار تحت نحو 2.5 B MACs، بجانب نموذجين كفؤين مصممين يدويًا هما MobileNetV2 وShuffleNet. ويضيف Once-for-All فكرة أخرى: درّب شبكة كبيرة واحدة مرة واحدة، ثم اقتطع منها شبكات فرعية متخصصة لكل جهاز، وهذا ما يجعل 80.0% عند 595 M ميسورة التكلفة في إنتاجها وليس في تشغيلها فقط.
The frontier and why it moves leftالحدّ ولماذا يتحرك نحو اليسار
The two arrows on the slide, "the higher the better" and "the lower the better", state the accuracy-efficiency trade-off as a partial order. Model A dominates model B if A is at least as accurate and at most as costly, with one of the two strictly better. The models nobody dominates form the Pareto frontier, the staircase you saw in the last visual. Every point below or to the right of it is a worse deal than something already available. Architecture search did not just add good models; it moved the entire staircase left, so that the best accuracy at 0.6 B MACs today exceeds the best at 8 B a few years earlier.
السهمان في الشريحة، "the higher the better" (الأعلى أفضل) و"the lower the better" (الأقل أفضل)، يعبّران عن مقايضة الدقة والكفاءة بوصفها ترتيبًا جزئيًا. النموذج A يهيمن على النموذج B إذا كان A بالدقة نفسها على الأقل وبالتكلفة نفسها على الأكثر، مع تفوّق صارم في أحد الاثنين. النماذج التي لا يهيمن عليها أحد تشكّل حدّ باريتو، وهو الدرج الذي رأيته في الشكل الأخير. كل نقطة تحته أو إلى يمينه صفقة أسوأ من شيء متاح بالفعل. البحث عن المعماريات لم يكتفِ بإضافة نماذج جيدة، بل نقل الدرج كله نحو اليسار، بحيث صارت أفضل دقة عند 0.6 B MACs اليوم تتجاوز أفضل دقة عند 8 B قبل بضع سنوات.
- Selectedالمختار
- IGCV3-D
- Baselineخط الأساس
- ResNet-50
- Parametersالمعاملات
- 3.5 M
- Sourceالمصدر
- read from the chartمقروءة من الرسم البياني
The dashed staircase is the Pareto frontier of the visible set: a point stays on it only when no other visible model has both higher accuracy and fewer MACs. Switch from Handcrafted to AutoML and watch the frontier jump left. Values marked as read from the chart are approximate.الدرج المتقطع هو حد باريتو (Pareto frontier) للنماذج الظاهرة: تبقى النقطة عليه فقط إذا لم يوجد نموذج ظاهر آخر يجمع بين دقة أعلى وعدد أقل من MACs. انتقل من Handcrafted إلى AutoML وراقب الحد يقفز إلى اليسار. القيم الموسومة بأنها مقروءة من الرسم البياني تقريبية.
The slide names the payoff in two lines. Efficient deep learning enables daily-life applications on mobile phones, which is why the Once-for-All paper defines a "mobile setting" as anything under 600 M MACs and reports being the first to reach 80% inside it. And it enables private on-device Inference and training, the theme of the last concept in this part. Both follow from the same fact: a model that costs fourteen times less can live on a device that has fourteen times less to spend.
تسمّي الشريحة المكسب في سطرين. التعلم العميق الكفء يمكّن تطبيقات الحياة اليومية على الهواتف المحمولة، ولهذا تعرّف ورقة Once-for-All "البيئة المحمولة" (mobile setting) بأنها أي شيء تحت 600 M MACs، وتذكر أنها أول من وصل إلى 80% داخلها. ويمكّن كذلك Inference والتدريب على الجهاز بخصوصية، وهو موضوع المفهوم الأخير في هذا الجزء. كلاهما ينتج من الحقيقة نفسها: النموذج الذي يكلّف أقل بأربع عشرة مرة يمكنه أن يعيش على جهاز لديه أقل بأربع عشرة مرة لينفقه.
Quick checkاختبار سريع
Xception needs about 8.4B MACs for 79.0% top-1 and Once-for-All 595M MACs for 80.0%. By what factor is computation reduced?يحتاج Xception إلى نحو 8.4B MACs لدقة top-1 تبلغ 79.0%، ويحتاج Once-for-All إلى 595M MACs لدقة 80.0%. بأي معامل تقل الحوسبة؟
Recall
ResNet-50 needs 3.9B MACs, Xception 8.4B, and Once-for-All 595M. Compute both reduction ratios.يحتاج ResNet-50 إلى 3.9B MACs، وXception إلى 8.4B، وOnce-for-All إلى 595M. احسب نسبتي التقليل.
Slide 7 shows two photographs of a small camera board on a desk. In one it reports whether the person in front of it wears a face mask; in the other it detects people in an office. There is no phone, no laptop and no network cable in the picture. The board is an OpenMV Cam, whose processor is an ARM Cortex-M7 Microcontroller (MCU), and the software is MCUNet, a framework from the same lab as Once-for-All (Lin et al., 2020).
تعرض الشريحة 7 صورتين للوحة كاميرا صغيرة على مكتب. في إحداهما تخبر اللوحة إن كان الشخص الذي أمامها يرتدي كمامة، وفي الأخرى تكتشف الأشخاص في مكتب. لا يوجد في الصورة هاتف ولا حاسوب محمول ولا كابل شبكة. اللوحة هي OpenMV Cam، ومعالجها Microcontroller (MCU) من نوع ARM Cortex-M7، والبرمجيات هي MCUNet، وهو إطار عمل من المختبر نفسه الذي أنتج Once-for-All (Lin et al., 2020).
This is TinyML: machine learning on devices with kilobytes of memory. MCUNet's reference target, the STM32F746, has 320 kB of SRAM and 1 MB of flash, and its Table 1 lines that up against a phone and a cloud GPU. The OpenMV Cam H7 in the photos is a somewhat larger sibling: STM32H743 at 480 MHz, with 1 MB of RAM in total, of which MCUNet's experiments use the 512 kB main SRAM block, and 2 MB flash (OpenMV). Both are bare-metal devices with no operating system and no DRAM. Slide 23 returns to these exact numbers as the tiny AI column of the hardware tiers. Its cloud and mobile columns are updated to an 80 GB GPU and a 256 GB phone, so expect those two cells to differ from the table below while the microcontroller column stays the same.
هذا هو TinyML: تعلم الآلة على أجهزة ذاكرتها بالكيلوبايت. الهدف المرجعي لـ MCUNet، وهو STM32F746، فيه 320 kB من SRAM و1 MB من flash، والجدول 1 في الورقة يضعه في مقابل الهاتف ووحدة GPU السحابية. لوحة OpenMV Cam H7 في الصور شقيقة أكبر قليلًا: STM32H743 بتردد 480 MHz، مع 1 MB من RAM إجمالًا، تستخدم تجارب MCUNet منها كتلة SRAM الرئيسية البالغة 512 kB، و2 MB من flash (OpenMV). كلا الجهازين يعمل مباشرة على العتاد (bare-metal) بلا نظام تشغيل وبلا DRAM. تعود الشريحة 23 إلى هذه الأرقام نفسها بوصفها عمود الذكاء الاصطناعي الصغير في مستويات العتاد. لكن عموديها للسحابة والهاتف محدّثان إلى GPU بسعة 80 GB وهاتف بسعة 256 GB، فتوقع أن تختلف هاتان الخانتان عن الجدول أدناه بينما يبقى عمود المتحكم الدقيق كما هو.
| Tierالمستوى | Memoryالذاكرة | Storageالتخزين | Gap from the tier aboveالفجوة عن المستوى الأعلى |
|---|---|---|---|
| Cloud AI (NVIDIA V100)ذكاء اصطناعي سحابي (NVIDIA V100) | 16 GB16 GB | TB to PBمن TB إلى PB | referenceالمرجع |
| Mobile AI (iPhone 11)ذكاء اصطناعي في الهاتف (iPhone 11) | 4 GB4 GB | more than 64 GBأكثر من 64 GB | 4x less memory, 1000x less storageذاكرة أقل بـ 4x، وتخزين أقل بـ 1000x |
| Tiny AI (STM32F746)ذكاء اصطناعي صغير (STM32F746) | 320 kB320 kB | 1 MB1 MB | table prints 3100x less memory, 64000x less storageيطبع الجدول ذاكرة أقل بـ 3100x، وتخزينًا أقل بـ 64000x |
Why nothing off the shelf fitsلماذا لا يتسع أي نموذج جاهز
The paper gives three failures. ResNet-50's weight storage is about 102 MB, 100x the flash. MobileNetV2 needs about 6.8 MB of peak activation memory, 22x the SRAM (the paper rounds up). Even the int8-quantized MobileNetV2 peaks at 1.7 MB, still 5.3x over, and that is before the runtime's own buffers. Reaching the board required designing the network and the inference engine together: TinyNAS searches architectures under the exact memory limits and TinyEngine executes them without interpreter overhead, and MCUNet as a whole uses 3.5x less SRAM and 5.7x less flash than int8 MobileNetV2 and ResNet-18 at similar accuracy. The result is 70.7% ImageNet top-1 on an STM32H743 (the OpenMV H7 chip, which MCUNet evaluates under a 512 kB SRAM and 2 MB flash budget, although the board has 1 MB of SRAM in total), the first time that bar was reached on an off-the-shelf microcontroller, and about 62% inside the 320 kB / 1 MB budget of the F746 (Lin et al., 2020, Table 4, 4-bit).
تذكر الورقة ثلاثة إخفاقات. تخزين الأوزان في ResNet-50 نحو 102 MB، أي 100x من سعة flash. ويحتاج MobileNetV2 نحو 6.8 MB من ذاكرة التنشيط القصوى، أي 22x من SRAM (الورقة تقرّب إلى الأعلى). وحتى MobileNetV2 المكمَّم بـ int8 تبلغ ذروته 1.7 MB، أي ما زال أكبر بـ 5.3x، وهذا قبل حساب المخازن المؤقتة الخاصة ببيئة التشغيل نفسها. الوصول إلى اللوحة تطلّب تصميم الشبكة ومحرك الاستدلال معًا: TinyNAS يبحث عن المعماريات تحت حدود الذاكرة الدقيقة، وTinyEngine ينفذها دون عبء المفسِّر، وMCUNet ككل يستخدم SRAM أقل بـ 3.5x وflash أقل بـ 5.7x مقارنة بـ MobileNetV2 وResNet-18 المكمَّمين بـ int8 بدقة مماثلة. والنتيجة دقة top-1 على ImageNet قدرها 70.7% على STM32H743 (شريحة OpenMV H7، التي يقيّمها MCUNet تحت ميزانية 512 kB من SRAM و2 MB من flash، مع أن في اللوحة 1 MB من SRAM إجمالًا)، وهي أول مرة يُبلغ فيها هذا المستوى على متحكم دقيق جاهز من السوق، ونحو 62% داخل ميزانية 320 kB / 1 MB الخاصة بـ F746 (Lin et al., 2020, Table 4, 4-bit).
Worked exampleمثال محلول
Does ResNet-50 fit?هل يتسع ResNet-50؟
Weights in FP32الأوزان بصيغة FP32
25.5 M parameters times 4 bytes is 102 MB, matching the paper.25.5 M معامل مضروبة في 4 بايت تساوي 102 MB، وهذا يطابق الورقة.Against 1 MB of flashمقابل 1 MB من flash
102 / 1 = 102x too large.102 / 1 = 102x أكبر من اللازم.Even at 8 bitsحتى بـ 8 بت
25.5 MB, still 25x too large; quantization alone cannot save it.25.5 MB، أي ما زال أكبر من اللازم بـ 25x، فالتكميم وحده لا يستطيع إنقاذه.Resultالنتيجة
Fitting a microcontroller needs a different architecture, not a compressed copy of a server model.ملاءمة متحكم دقيق تحتاج إلى معمارية مختلفة، لا إلى نسخة مضغوطة من نموذج خوادم.
The reasons to bother are the same four from the first concept, now at their most extreme. MCUNet points out that there are around 250 billion microcontrollers in the world, that processing raw sensor data at the source protects privacy because nothing is transmitted, and that inference on the node works in places without Internet access (Lin et al., 2020). A mask detector on a camera board costs a few dollars, runs on milliwatts and never uploads a face.
أسباب تحمّل هذا العناء هي الأسباب الأربعة نفسها من المفهوم الأول، لكنها الآن في أقصى صورها. يشير MCUNet إلى أن في العالم نحو 250 billion متحكم دقيق، وأن معالجة بيانات الاستشعار الخام عند مصدرها تحمي الخصوصية لأنه لا يُرسَل شيء، وأن الاستدلال على العقدة يعمل في أماكن بلا إنترنت (Lin et al., 2020). كاشف الكمامات على لوحة كاميرا يكلّف بضعة دولارات، ويعمل بالمللي واط، ولا يرفع وجهًا أبدًا.
Quick checkاختبار سريع
What memory gap does MCUNet's Table 1 print between a phone and the microcontroller?ما فجوة الذاكرة التي يطبعها الجدول 1 في MCUNet بين الهاتف والمتحكم الدقيق؟
Recall
What memory and storage does the MCU that MCUNet targets have, and how far is that from a cloud GPU?ما الذاكرة والتخزين في المتحكم الدقيق الذي يستهدفه MCUNet، وكم يبعد ذلك عن GPU سحابية؟
A smart speaker slowly gets better at recognizing the voices in one house. A phone learns its owner's face after the first enrollment. Both need data that arrives after the product shipped, and both kinds of data (a voice, a face) are exactly what users least want uploaded. The figure on slide 8 draws the consequence: new and sensitive data flows from the user to the Edge device, the arrow from the device to the cloud is crossed out for privacy, and a small loop above the device shows the model updating itself where the data is.
مكبّر الصوت الذكي يتحسن تدريجيًا في التعرف على أصوات أهل بيت واحد. والهاتف يتعلم وجه مالكه بعد التسجيل الأول. كلاهما يحتاج بيانات تصل بعد شحن المنتج، وكلا نوعي البيانات (صوت، وجه) هو بالضبط ما لا يريد المستخدمون رفعه. الشكل في الشريحة 8 يرسم النتيجة: بيانات جديدة وحساسة تتدفق من المستخدم إلى Edge device، والسهم من الجهاز إلى السحابة مشطوب لأسباب الخصوصية، وحلقة صغيرة فوق الجهاز تبيّن النموذج وهو يحدّث نفسه حيث توجد البيانات.
That loop is On-device training (learning). The slide lists four benefits. Better privacy, because nothing leaves the device. Lower cost, because there is no upload and no cloud training bill. Customization, because the model adapts to this user, this room, this camera angle. Life-long learning, because the adaptation never has to stop; AI systems, as the slide puts it, need to continually adapt to new data collected locally. Lin and colleagues summarize the goal as letting users benefit from customized models without transferring their data to the cloud (Lin et al., 2022).
هذه الحلقة هي On-device training (learning). تسرد الشريحة أربع فوائد. خصوصية أفضل، لأن لا شيء يغادر الجهاز. تكلفة أقل، لأنه لا يوجد رفع ولا فاتورة تدريب سحابي. التخصيص، لأن النموذج يتكيف مع هذا المستخدم، وهذه الغرفة، وزاوية الكاميرا هذه. التعلم مدى الحياة، لأن التكيف لا يجب أن يتوقف أبدًا، فأنظمة الذكاء الاصطناعي، كما تقول الشريحة، تحتاج إلى التكيف باستمرار مع البيانات الجديدة المجموعة محليًا. ويلخص Lin وزملاؤه الهدف بأنه تمكين المستخدمين من الاستفادة من نماذج مخصصة دون نقل بياناتهم إلى السحابة (Lin et al., 2022).
Why training is so much more expensive than inferenceلماذا التدريب أغلى بكثير من الاستدلال
The third line of the slide is the catch: training is more expensive than Inference, hard to fit in edge memory, and limited by power. All three follow from how backpropagation works. Inference is one forward pass through the layers, and each layer's activations can be discarded as soon as the next layer has consumed them. Training runs the same forward pass, then a backward pass that costs about twice as much: propagating the gradient through each layer is one multiply by the transposed weights, which Goodfellow, Bengio and Courville note has the same cost as the forward multiply (Goodfellow et al., 2016, Sec. 6.5.7), and computing the weight gradient is a second multiply of the same size. So one training step is roughly three times the arithmetic of one inference pass, the convention behind the 6N versus 2N per-token estimate used in scaling studies (Kaplan et al., 2020). The backward pass also needs the activations that the forward pass produced. Goodfellow and colleagues put it directly: the input to each hidden nonlinearity must be stored from the moment it is computed until the backward pass has returned to the same point, so memory grows with the number of examples in the batch and the width of the layers. On top of that, the optimizer keeps its own state: a momentum buffer, or two moment estimates for Adam, each the size of the model.
السطر الثالث في الشريحة هو العقبة: التدريب أغلى من Inference، ويصعب احتواؤه في ذاكرة الحافة، ومحدود بالطاقة. والثلاثة تنتج من طريقة عمل الانتشار العكسي (backpropagation). الاستدلال تمرير أمامي واحد عبر الطبقات، ويمكن التخلص من تنشيطات كل طبقة بمجرد أن تستهلكها الطبقة التالية. أما التدريب فيجري التمرير الأمامي نفسه، ثم تمريرًا عكسيًا يكلّف نحو الضعف: نشر التدرج عبر كل طبقة هو عملية ضرب واحدة في الأوزان المنقولة (transposed)، ويذكر Goodfellow وBengio وCourville أن تكلفتها تساوي تكلفة الضرب الأمامي (Goodfellow et al., 2016, Sec. 6.5.7)، وحساب تدرج الأوزان عملية ضرب ثانية بالحجم نفسه. إذن خطوة تدريب واحدة تساوي تقريبًا ثلاثة أضعاف الحساب في تمرير استدلال واحد، وهذا هو الاصطلاح وراء تقدير 6N مقابل 2N لكل رمز (token) المستخدم في دراسات التوسع (Kaplan et al., 2020). ويحتاج التمرير العكسي أيضًا إلى التنشيطات التي أنتجها التمرير الأمامي. يقولها Goodfellow وزملاؤه صراحة: مدخل كل لاخطية مخفية يجب تخزينه من لحظة حسابه حتى يعود التمرير العكسي إلى النقطة نفسها، فتنمو الذاكرة مع عدد الأمثلة في الدفعة (batch) ومع عرض الطبقات. وفوق ذلك يحتفظ المُحسِّن (optimizer) بحالته الخاصة: مخزن للزخم (momentum)، أو تقديران للعزوم في حالة Adam، كلٌّ منها بحجم النموذج.
| Resourceالمورد | Inferenceالاستدلال | Trainingالتدريب |
|---|---|---|
| Compute per exampleالحوسبة لكل مثال | One forward passتمرير أمامي واحد | Forward plus backward, about 3x the multiply-adds (backward is about 2x forward)تمرير أمامي ثم خلفي، أي نحو 3x من عمليات الضرب والجمع (التمرير الخلفي يكلّف نحو 2x الأمامي) |
| Activationsالتنشيطات | Freed layer by layer as the input flows throughتُحرَّر طبقةً بعد طبقة مع مرور المدخل | Every layer's activations kept until the backward pass returnsتُحفظ تنشيطات كل طبقة حتى يعود التمرير الخلفي إليها |
| Extra stateالحالة الإضافية | Weights onlyالأوزان فقط | Weights, gradients and optimizer state (momentum, Adam moments)الأوزان والتدرجات وحالة المُحسِّن (الزخم، وعزوم Adam) |
| Memory scalingنمو الذاكرة | Largest single layerأكبر طبقة منفردة | Grows with depth and batch sizeتنمو مع العمق وحجم الدفعة |
Worked exampleمثال محلول
Training MobileNetV1 on a microcontroller, naivelyتدريب MobileNetV1 على متحكم دقيق بطريقة ساذجة
Weightsالأوزان
4.2 M parameters in FP32 is 16.8 MB.4.2 M معامل بصيغة FP32 تساوي 16.8 MB.Gradients and momentumالتدرجات والزخم
One gradient per weight and one momentum value per weight: two more copies, another 33.6 MB.تدرج واحد لكل وزن وقيمة زخم واحدة لكل وزن: نسختان إضافيتان، أي 33.6 MB أخرى.Total before activationsالمجموع قبل التنشيطات
50.4 MB of state, against 320 kB of SRAM.50.4 MB من الحالة، مقابل 320 kB من SRAM.Resultالنتيجة
About 157x over budget before a single activation is stored. Lin et al. (2022) get training under 256 kB by updating only a sparse subset of weights and by training directly on quantized values, using less than a thousandth of the memory of PyTorch or TensorFlow on the same task.تجاوز للميزانية بنحو 157x قبل تخزين تنشيط واحد. ويصل Lin et al. (2022) بالتدريب إلى أقل من 256 kB بتحديث مجموعة جزئية متفرقة (sparse) فقط من الأوزان وبالتدريب مباشرة على القيم المكمَّمة، مستخدمين أقل من جزء من الألف من ذاكرة PyTorch أو TensorFlow في المهمة نفسها.
Power is the last constraint. A training step roughly triples the arithmetic of every example, and a device that runs on a battery or a solar cell cannot run it continuously. So on-device learning is not merely inference plus a little bookkeeping; it is a harder problem than the one MCUNet solved, and the course treats it as its own topic.
الطاقة هي القيد الأخير. خطوة التدريب تضاعف حساب كل مثال ثلاث مرات تقريبًا، والجهاز الذي يعمل ببطارية أو بخلية شمسية لا يستطيع تشغيلها باستمرار. لذا فالتعلم على الجهاز ليس مجرد استدلال مع قليل من العمليات الإضافية، بل مشكلة أصعب من التي حلّها MCUNet، والمقرر يعاملها موضوعًا مستقلًا.
Quick checkاختبار سريع
Why does the slide 8 figure cross out the arrow from the edge device to the cloud?لماذا يشطب شكل الشريحة 8 السهم من جهاز الحافة إلى السحابة؟
Recall
Give three reasons training is more expensive than inference on a device, and the four benefits of doing it anyway.اذكر ثلاثة أسباب تجعل التدريب أغلى من الاستدلال على الجهاز، والفوائد الأربع للقيام به رغم ذلك.
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Machine learning and deep learning are everywhere and computationally expensive; the course asks how to make them lightweight and fast without losing accuracy.التعلم الآلي والتعلم العميق موجودان في كل مكان ومكلفان حسابيًا، والمقرر يسأل كيف نجعلهما خفيفين وسريعين دون أن نخسر الدقة.
- Progress rides on three pillars, algorithm, hardware and data; efficiency work in this course lives mainly in the first two.يقوم التقدم على ثلاث ركائز: الخوارزمية والعتاد والبيانات، وعمل الكفاءة في هذا المقرر يقع أساسًا في الركيزتين الأوليين.
- ImageNet top-5 error fell from 28.2% (2010) to 2.3% (2017); AlexNet cut 9.4 points in 2012; ResNet (3.57%) was the first winner below the 5.1% human estimate.انخفض خطأ top-5 على ImageNet من 28.2% (عام 2010) إلى 2.3% (عام 2017)، وخفّضه AlexNet بمقدار 9.4 نقطة في 2012، وكان ResNet (3.57%) أول فائز يقل عن التقدير البشري البالغ 5.1%.
- Top-5 error and top-1 accuracy are different metrics: slide 4 uses the first, slides 5 and 6 the second.خطأ top-5 ودقة top-1 مقياسان مختلفان: الشريحة 4 تستخدم الأول، والشريحتان 5 و6 تستخدمان الثاني.
- MACs count multiply-accumulates per input, a hardware-neutral cost; parameters count storage. More of both buys accuracy with diminishing returns (ResNet-101 doubles the MACs of ResNet-50 for about 1 point).تعدّ MACs عمليات الضرب والجمع التراكمي لكل مدخل، وهي تكلفة مستقلة عن العتاد، بينما يعدّ عدد المعاملات التخزين. زيادة الاثنين تشتري الدقة بعائد متناقص (ResNet-101 يضاعف MACs مقارنة بـ ResNet-50 مقابل نقطة واحدة تقريبًا).
- Once-for-All (595M MACs, 80.0% top-1) beats Xception with 14x less computation, shifting the Pareto frontier to the upper left.يتفوق Once-for-All (595M MACs، ودقة top-1 تبلغ 80.0%) على Xception بحوسبة أقل بـ 14 مرة، فينزاح حدّ باريتو نحو الأعلى واليسار.
- MCUNet runs mask and person detection on a Cortex-M7 camera board; its reference MCU has 320 kB SRAM and 1 MB Flash, three to four orders of magnitude below a phone.يشغّل MCUNet كشف الكمامات وكشف الأشخاص على لوحة كاميرا بمعالج Cortex-M7، ومتحكمه المرجعي فيه 320 kB من SRAM و1 MB من Flash، أي أقل من الهاتف بثلاث إلى أربع رتب عشرية.
- On-device learning gives privacy, lower cost, customization and life-long learning, but a training step costs roughly three times the compute of an inference pass plus stored activations and optimizer state, on limited memory and power.التعلم على الجهاز يمنح الخصوصية وتكلفة أقل والتخصيص والتعلم مدى الحياة، لكن خطوة التدريب تكلّف نحو ثلاثة أضعاف حوسبة تمرير الاستدلال، إضافة إلى تخزين التنشيطات وحالة المُحسِّن، على ذاكرة وطاقة محدودتين.
Sourcesالمصادر
- ImageNet Large Scale Visual Recognition ChallengePaperInternational Journal of Computer Vision, Russakovsky et al., 2015Top-5 definition (Eq. 1), winners 2010 to 2014, human 5.1% (Sec. 6.4)تعريف top-5 (المعادلة 1)، والفائزون من 2010 إلى 2014، والأداء البشري 5.1% (القسم 6.4)(opens in a new tab)(يفتح في تبويب جديد)
- Deep Residual Learning for Image RecognitionPaperCVPR 2016, He, Zhang, Ren, Sun3.57% top-5 ensemble; Table 1 multiply-adds for ResNet-50 and ResNet-101مجموعة نماذج بخطأ top-5 قدره 3.57%، والجدول 1 لعمليات الضرب والجمع في ResNet-50 وResNet-101(opens in a new tab)(يفتح في تبويب جديد)
- ImageNet Classification with Deep Convolutional Neural NetworksPaperNeurIPS 2012, Krizhevsky, Sutskever, HintonAlexNet: 1.2 million training images, two GTX 580 GPUs, the prediction panel on slide 4AlexNet: نحو 1.2 million صورة تدريب، ووحدتا GTX 580، ولوحة التنبؤات في الشريحة 4(opens in a new tab)(يفتح في تبويب جديد)
- Squeeze-and-Excitation NetworksPaperCVPR 2018, Hu, Shen, Sun2.251% top-5, ILSVRC 2017 winnerخطأ top-5 قدره 2.251%، الفائز في ILSVRC 2017(opens in a new tab)(يفتح في تبويب جديد)
- ILSVRC 2016 resultsDocsImageNetTrimps-Soushen 2.991% top-5Trimps-Soushen بخطأ top-5 قدره 2.991%(opens in a new tab)(يفتح في تبويب جديد)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017Table 8: 70.6% top-1, 569 M multiply-adds, 4.2 M parametersالجدول 8: دقة top-1 تبلغ 70.6%، و569 M عملية ضرب وجمع، و4.2 M معامل(opens in a new tab)(يفتح في تبويب جديد)
- Once-for-All: Train One Network and Specialize it for Efficient DeploymentPaperICLR 2020, Cai, Gan, Wang, Zhang, Han80.0% top-1 at 595 M MACs, Figure 2 with the 14x arrow, mobile setting under 600 M MACs, CO2 of five carsدقة top-1 تبلغ 80.0% عند 595 M MACs، والشكل 2 مع سهم 14x، وإعداد الهاتف تحت 600 M MACs، وانبعاثات CO2 لخمس سيارات(opens in a new tab)(يفتح في تبويب جديد)
- Model Compression and Hardware Acceleration for Neural Networks: A Comprehensive SurveyPaperProceedings of the IEEE 108(4), Deng, Li, Han, Shi, Xie, 2020Credited on slide 5; DOI 10.1109/JPROC.2020.2976475منسوب إليه الشكل في الشريحة 5، DOI 10.1109/JPROC.2020.2976475(opens in a new tab)(يفتح في تبويب جديد)
- Efficient Processing of Deep Neural Networks: A Tutorial and SurveyPaperProceedings of the IEEE, Sze, Chen, Yang, Emer, 2017MAC as the fundamental operation; ResNet-50 25.5 M weights and 3.9 G MACsعملية MAC بوصفها العملية الأساسية، وResNet-50 بـ 25.5 M وزن و3.9 G MACs(opens in a new tab)(يفتح في تبويب جديد)
- Xception: Deep Learning with Depthwise Separable ConvolutionsPaperCVPR 2017, CholletSame parameter count as Inception V3عدد المعاملات نفسه في Inception V3(opens in a new tab)(يفتح في تبويب جديد)
- MCUNet: Tiny Deep Learning on IoT DevicesPaperNeurIPS 2020, Lin, Chen, Lin, Cohn, Gan, HanTable 1 tiers, STM32F746 320 kB and 1 MB, 7.2 MB and 6.8 MB peak memory, 100x, 22x and 5.3x overshoots, Table 4 70.7% on H743 and 62.0% on F746, 250 billion MCUsمستويات الجدول 1، وSTM32F746 بـ 320 kB و1 MB، وذروة ذاكرة 7.2 MB و6.8 MB، وتجاوزات بمقدار 100x و22x و5.3x، والجدول 4 بدقة 70.7% على H743 و62.0% على F746، و250 مليار متحكم دقيق(opens in a new tab)(يفتح في تبويب جديد)
- OpenMV Cam H7DocsOpenMVSTM32H743 Cortex-M7 at 480 MHz, 1 MB RAM in total (512 kB main SRAM used by MCUNet), 2 MB flashSTM32H743 بمعالج Cortex-M7 عند 480 MHz، و1 MB من RAM إجمالًا (يستخدم MCUNet منها 512 kB من SRAM الرئيسية)، و2 MB من flash(opens in a new tab)(يفتح في تبويب جديد)
- On-Device Training Under 256KB MemoryPaperNeurIPS 2022, Lin, Zhu, Chen, Wang, Gan, HanCustomized models without transferring data to the cloud; training under 256 kB SRAMنماذج مخصصة دون نقل البيانات إلى السحابة، وتدريب تحت 256 kB من SRAM(opens in a new tab)(يفتح في تبويب جديد)
- Deep Learning, chapter 6: Deep Feedforward NetworksBookMIT Press, Goodfellow, Bengio, Courville, 2016Sec. 6.5.7: the backward multiply by the transposed weights costs the same as the forward one; activations stored until the backward pass returnsالقسم 6.5.7: الضرب الخلفي في الأوزان المنقولة يكلّف مثل الضرب الأمامي، والتنشيطات تُحفظ حتى يعود التمرير الخلفي(opens in a new tab)(يفتح في تبويب جديد)
- Scaling Laws for Neural Language ModelsPaperKaplan et al., 2020Training compute of about 6N versus 2N for inference per token, the backward-is-twice-forward conventionحوسبة التدريب نحو 6N مقابل 2N للاستدلال لكل رمز (token)، وهو اصطلاح أن التمرير الخلفي ضعف الأمامي(opens in a new tab)(يفتح في تبويب جديد)
- Going Deeper with ConvolutionsPaperCVPR 2015, Szegedy et al.GoogLeNet, the 22-layer ILSVRC 2014 winnerGoogLeNet، الشبكة ذات 22 طبقة الفائزة في ILSVRC 2014(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940: TinyML and Efficient Deep Learning ComputingDocsMIT HAN Lab, Song HanCompanion course whose introduction lecture the deck followsالمقرر المرافق الذي تتبع الشرائح محاضرته التمهيدية(opens in a new tab)(يفتح في تبويب جديد)