江衍涵
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Once for All ## 1.Introduction 要設計一個可以針對不同場景所使用的網路是很花費時間和人力的,即使是現在的AutoML方法,也需要不斷的重新搜索不斷的重新訓練,因此在這樣的情況下,搜索的時間花費會隨著場景的數量線性成長,使得過去的NAS並沒有辦法應付如此大量且多元的硬體環境。 此論文提出了once-for-all network,可以在不同的硬體限制下,直接部屬,不用重新訓練不用重新搜索,只需要查詢表格的方式便可以決定網路的架構,且可以彈性的應對不同的depths,widths,kernel size和resolutions。 訓練OFA網路架構等同於訓練大量的子網路(此論文中,為10¹⁹個子網路),而利用weight sharing的方式,雖然可以不用訓練10¹⁹個網路,但是要在weight sharing的情況下讓子網路之間不會互相干擾更加的困難。因此在這篇論文中,作者提出了progressive shrinking algorithm的方式來訓練once-for-all network ![](https://i.imgur.com/V4oBiB0.png) * 為了適應不同的硬體平台裝置和效率的限制,研究人員需單獨設計合適的深度學習網路結構或壓縮網路結構加速現有的模型。 * 此研究設計一個在不重新模型訓練的情況下,在不同小硬體裝置部署合適深度(depth)、寬度(width)、核大小(kernel)、解析度(resolution)的模型,能達到高準確率設置。 * OFA 訓練整個網路架構時,子網路從過程中生成,每個子網路在不相互影響下計算準確率(Accuracy)、延遲(Latency),子網路的權重值由預訓練的權重中得到,並在不同硬體設備中獲得子網路準確率 * progressive shrinking algorithm: 首先訓練一個深度(depth)、寬度(width)、核大小(kernel)都是最大的網格,再逐一縮減。 ## 2.Method **Progressive shrinking algorithm** 此研究從四個維度考慮深度模型的網路結構,深度、宽度、核大小、解析度,目標是把子網路都能和另外單獨訓練的模型在同一個級別的準確率。 先訓練大的模型再訓練小的模型,透過保留較大模型中重要的參數,使得子網路有的初始值不用從頭訓練。訓練的過程中,同時使用hard labels和soft labels來進行訓練,如下: $$ Loss = Loss_{hard} + λLoss_{soft} $$ 最終的目的是希望訓練once-for-all network可以同時支援所有的子網路,並使所有的子網路達到相同程度的收斂(如同獨立的個別訓練所有的子網路) ![](https://i.imgur.com/o6dwlcR.png) 1. **Elastic Resolution** 訓練的時候,會隨機將照片放大或是縮小,在OFA網路能夠接受不同尺寸影像的輸入 3. **Elastic Kernel Size** 理論上,7x7的convolution kernel的中間區塊是可以被當作是5x5的convolution kernel,而5x5的convolution kernel的中間區塊是可以被當作是3x3的convolution kernel。實際上會遇到一個問題,中間被共享的參數是需要扮演多個角色的,而強制的使它們在扮演不同角色時使用相同的參數會使網路的準確度變差。利用了kernel transform matrices來進行kernel間的weight sharing,也就是使用不同的kernel時,會先將原先的參數乘上kernel transform matrices,將參數的分佈轉換成較符合不同kernl的分佈。 ![](https://i.imgur.com/LmwaIJ4.png) 5. **Elastic Depth** Elastic Depth支援stage-level,也就是一連串相同output resolution的blocks。舉例來說,原先在同一個stage有N個block的once-for-all network,任何子網路都可以從這N個block中取出D個block來使用,而剩下的N-D個block便會直接跳過,因此這前D個block在最後會同時被較大的子網路以及較小的子網路共用。 ![](https://i.imgur.com/IIaMXiU.png) 7. **Elastic Width** Width代表的是channel size的數量,也就是允許每一層可以彈性的選擇不同的expansion ratio。遵循著 progressive shrinking scheme,在一開始會訓練擁有最大的width的網路。而作者使用了channel sorting operation來確認不同channel之間的重要程度,而實做的方式是計算每一層weight的L1 Norm,較大的代表這個channel是比較重要的,舉例來說,假如要從4-channel-layer切割成3-channel-layer,便會選擇最重要的3個channel-layer(也就是L1 Norm最大的前3個),透過這個方式,子網路會被初始化會最重要的channel。 ![](https://i.imgur.com/lIp3FUQ.png) **Specialized Model Deployment with Once-for-all Network** 訓練好OFA後,下一步是需要能夠根據不同的硬體設備需求來取出最適合的子網路了。在此目的是針對目標硬體的限制(例如:e.g., latency, energy),去最佳化模型的準確率。而OFA將訓練網路和搜索網路架構拆開來,在這個階段是完全不需要任何的訓練成本的。 此研究從OFA中,隨機採樣不同架構與輸入影像大小的16K個子網路,再隨機抽取10K驗證集圖像,建構準確度表格。 ## 3.Experiments 此研究在ImageNet dataset上面訓練OFA,並再根據許多不同的硬體設備 (Samsung Note8, Google Pixel1, Pixel2, NVIDIA 1080Ti, 2080Ti, V100 GPUs, and Intel Xeon CPU)的資源限制切出最適合的子網路。 ### 3.1 Training the OFA network on IMAGENET #### 訓練細節: 此研究OFA網路共包含2 × 10¹⁹ 子網路,使用MobileNetV3的模型架構,在用SGD優化器在每一個子網路,模型訓練180個epoch,在 ImageNet 數據集上batch size為2048 ,在32塊V100的GPU上共計花費1200小時 #### 結果: 結果如圖7所示,分别使此研究的漸進收縮(PS)演算法和不使用PS進行訓練。以8個子網路做比較,PS可以提高ImageNet的子網路準確性,準確性提高3.3%。 ![](https://i.imgur.com/dc59bFk.png) ### 3.2 Specialized Sub-networks for Different Hardware Platforms and Constraints 將訓練好的OFA子網路應用在不同平台,從雲端設備到硬體邊緣運算,根據不同的裝置搭配最好的網路架構。圖九為OFA 應用在六種不同手機的ImageNetV3模型,綠色曲線為OFA 訓練一次所得到的準確率,藍色曲線為單獨訓練為模型單獨訓練的準確率,OFA 僅需訓練一次即可確認最佳模型架構,模型準確率甚至比個別模型訓練高。 ![](https://i.imgur.com/Jg1aOkf.png) ### 3.3 Comparison with NAS on Mobile Devices 跟過去其他NAS的方法進行比較,OFA更加的有效率,因為對於不同的情況下,OFA都只需要固定的訓練時間和搜索時間,而有利用PS使得OFA在沒有重新訓練的情況下可以跟其他的方法得到差不多的準確率甚至更高,而在進行了25個epochs的fin-tune之後,準確率甚至可以達到76.9。 ![](https://i.imgur.com/doRFZ1k.png) ## 4. Conclusion 這篇論文提出了Once for All(OFA),一個新的NAS方法,將訓練模型和搜索模型拆開來,使得在非常大量的架構需求下也可以很有效率的針對不同情況找到最好的網路模型。不同於以往對於每個需求都重新搜索重新訓練的NAS,once-for-all network在各種硬體平台與效能約束下進行實驗,證明可以同時支援非常多樣的架構設定,並減少大量的GPU訓練成本。且不會讓once-for-all network子網路互相干擾,提出了progressive shrinking algorithm,使得每個子網路可以達到不比獨立訓練差的準確度。 ## 參考資料 * https://openreview.net/forum?id=HylxE1HKwS * https://medium.com/ai-academy-taiwan/nas%E8%AB%96%E6%96%87%E5%B0%8E%E8%AE%80-once-for-all-train-one-network-and-specialize-it-for-efficient-deployment-1aee927d8dd5 * https://blog.csdn.net/weixin_39505272/article/details/100184165 softlabel: 以概率值/可能性表示分類種類, ex:[0.4,0.1,0.9] hardlabel: 以binary指定種類, ex:[0,0,1]

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully