Hu Josh
    • 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
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • 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

      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.
      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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
Engagement control Commenting, Suggest edit, Emoji Reply
  • 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

    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.
    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
    1
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: 神經網路優化技巧 tags: Templates, Talk description: nn optimization . --- # 神經網路優化技巧 <!-- Put the link to this slide here so people can follow --> https://hackmd.io/@joshhu/SJ2UG4UdS --- * 針對資料 * 針對神經元 * 針對整個神經網路 * 針對損失函數 * 針對啟動函數 * 針對層 * 針對參數 --- ## 使用這些技術的目的 --- 1. 提高模型的準確度 2. 加快達到訓練效果的時間 3. 防止overfitting 5. Inference的速度 6. 對抗雜訊的能力 --- ## 提高模型準確率 --- 1. Confusion Matrix 2. F1 Score其它資訊 --- ## 模型準確率 --- 1. 訓練集上有沒有好的結果 1. 訓練集結果不好,不是過度擬合(overfitting),需做調整(如dropout) 1. 測試集上有沒有好的結果 1. 測試集上沒有好結果,就是過度擬合 1. 測試集上結果也好,表示模型訓練成功 --- ## 優化流程 ![](https://i.imgur.com/nhALciN.png) --- ## 網路優化調整的對象 --- 1. 變更整個網路架構(換一組新的H) 1. 針對訓練資料集的變更 1. 針對訓練參數的調整 1. 網路參數的調整 1. 損失函數 1. 最佳化方法 1. 使用一個或多個GPU,或分散式系統(k8s) --- ## 變更整個網路架構 --- 1. 變換一種大架構 2. 變更神經元的種類(啟動函數, RELU) 3. 變換不同的模型,如把resnet換成densnet 4. Dropout(大多只用在fully connected layers) 5. batch norm 6. 模型的參數量會影響很多地方:訓練時間、記憶體的使用、硬體的使用、佈署、參考的時間 --- ### 變換一種大架構 --- 1. 把線性換成非線性 2. 變更神經元的類型 3. 把非線性換成NN 4. 把NN換成DNN 5. 把DNN換成CNN 6. 把CNN換成更複雜的架構,如inception 7. 增加複雜度,即增加函數的分佈空間 8. 如$y=w_1x^2+w_2x+b$這個非線性,一定包含$w_2x+b(w_1=0)$這個線性解 --- ### 模型參數量的影響 --- 1. 這個model是否train的起來 2. 準確度 3. 訓練時間 4. 記憶體的使用 5. 硬體的使用佈署 6. Inference的時間 --- ### 變更Activation Function ![](https://i.imgur.com/tz8ghYU.png) --- ### Gradient Vanishing ![](https://i.imgur.com/NWhbXdZ.png) --- ### Gradient Vanishing --- 靠近輸入層Gradient值非常小,靠近輸出層的Gradient很大,相同學習率靠近輸入層參數updata會很慢,靠近輸出層的參數updata會很快。當前幾層都還沒有更動參數的時候(隨機),之後幾層的參數就已經收斂了。 --- ## 針對訓練資料集的變更 --- 1. 獲得更多分佈更平均的訓練資料 1. Feature Scaling 1. Data augmentation 1. 資料集train, val, test比例的改變 1. 使用CV調整資料集的圖型特值 1. 變換資料集的顏色空間 1. Data balancing 1. Generative model(autoencoders, GAN) 1. Weighted Random Sampler --- ## 訓練時參數的調整 --- 1. 批次大小(batch size) 1. 輪數(epoch) 1. 提早結束(Early stopping) --- ## 網路參數的調整 --- 1. Batch norm 1. Weights, biases的初始化 1. Activation Function(變更神經元) 1. 防止梯度消失或梯度膨脹 1. Softmax --- ## 損失函數的調整 --- 1. 更換損失函數MSE、BCE、CCE 1. L1, L2 Regularization 1. L1, L2 Lamda值 1. 讓損失函數更平滑(更好微分) 2. Focal Loss --- ## 最佳化方法的調整 --- 1. 更換最佳化方法 1. 學習率的調整 1. Hessian, LBFG 1. Momentum-based 1. Adagrad, RMSProp, ADAM, momentum 1. Adaptive learning rates --- ## 最佳化方法的調整 --- 1. 更換最佳化方法 1. 學習率的調整 1. Hessian, LBFG 1. Momentum-based 1. Adagrad, RMSProp, ADAM, momentum 1. Adaptive learning rates ---

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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