Untitled Project
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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 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
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • 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 Help
Menu
Options
Engagement control 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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 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
    # Machine Learning ###### tags: `賴` `CNN` `Maching Learning` ![](https://i.imgur.com/ovMPEsk.png) - Machine Learning 演算法(Algorithms) 不只有 **Neural Network**,還包括 **K-Means**、**Support Vector Machines(SVM)**、**Decision Tree**等等,基本上,都是希望透過資料**分類(Classification)或分群(Clustering) 的方式,轉換為規則或知識,一般進行的步驟如下: 1. **訓練**:首先將已知的歷史資料,依資料特徵(譬如性別、年齡),將樣本作分類(譬如男人、女人、小孩),這就是所謂的訓練(Training)。 2. **建立模型(Model)**:訓練之後,我們就會得到一個模型(簡略的講,就是公式),推算未知的資料是哪一類,例如性別是男,年齡大於18歲,模型就推斷他是男人;反之,年齡小於18歲,不論性別,模型就推斷他是小孩。 3. **評估(Evaluation)**:隨機抓一部分的已知資料,測試模型的準確率(或其他評估指標,如 precision and recall),確定模型是堪用的,這就是『驗證』(Validation),有了評估指標,我們就可以跟老闆或客戶,拍胸脯、打包票,不準就切腹自盡(千萬不要喔)。 4. **預測(Prediction)**:有了以上模型後,一個未知的人進來後,我們就可以依據性別及年齡推斷,他/她是男人、女人或小孩? 但是,注意! Machine Learning 不是以程式撰寫明確的規則(If ... Then ...Else),而是『以已知的資料推斷未知的資料』,只要,不斷餵資料,機器就慢慢的變聰明了。 ## 神經網路(Neural Network) ![](https://i.imgur.com/V3y1fTi.png) - 主要是模仿生物的神經系統,透過層層連接的『神經元』(Neuron),建立傳導的模型,以推論輸入(Input)到輸出(Output)的過程。 - Input Layer 就是接收信號的神經元,Hidden Layer 就是隱藏層,而 Output Layer 就是做出反應的輸出層。而各神經元傳導的力量大小,稱為權重(Weight, 以W表示),也就是模型要求解的參數。如果求算出來,我們就得到一道公式,只要輸入信號,經過層層傳導,就可以推斷出結果了。 - ![](https://i.imgur.com/BcxYHRh.png) - Hidden Layer及Output Layer上每一個節點(圓圈)的值等於上一層所有節點的加權總和 - 統計學的簡單迴歸(Regression),迴歸要計算權重值(W),我們可以用『最小平方法』(Least Square),最小化『預測值與實際值的差距之平均值』(如下圖右),或者使用『線性規劃』(Linear Programming) 最小化目標函數,也可以求得W。 | ![](https://i.imgur.com/R8IMMFd.png) | ![](https://i.imgur.com/4pHzLCm.png) | | -------- | -------- | | 簡單迴歸(Regression) | 預測值與實際值的差距之平均值| - https://ithelp.ithome.com.tw/articles/10191528 - 所以,一個模型的好壞取決於我們採用何種『損失函數』、『成效衡量指標』(Metrics)、Activation Function、優化器(optimizer)、隱藏層數(Layers或Dense)、kernel_initializer以及它們使用的參數 - - https://ithelp.ithome.com.tw/articles/10191725 ## CNN卷積神經網路 - 取周遭 N x N 格的點構成一個面(N 稱為 Kernel Size,N x N 的矩陣權重稱為『卷積核』),每一格給予不同的權重,計算加權總和,當作這一點的 output,再移動至下一點以相同方式處理,至圖像的最後一點為止 - [How do Convolutional Neural Networks work?](https://brohrer.mcknote.com/zh-Hant/how_machine_learning_works/how_convolutional_neural_networks_work.html) ## CNN運算流程 - https://chih-sheng-huang821.medium.com/%E5%8D%B7%E7%A9%8D%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF-convolutional-neural-network-cnn-cnn%E9%81%8B%E7%AE%97%E6%B5%81%E7%A8%8B-ecaec240a631 ### 卷積 - 提取圖片中的特徵(feature) - ![](https://i.imgur.com/sT31OjT.png) - 先透過濾鏡(filter)來提取圖片特徵(feature),轉換影像,例如取影像中的邊緣、銳利化、模糊化等等,透過不同的 filter 來盡可能取得影像特徵,然後再將這些特徵作為後面 Neuron 的輸入 - 一般在影像上,捲積運算後會再加上激活函數(activation function),進行非線性轉換,之後得到的圖片會稱為特徵圖(feature map)。 Feature map{i} = original Data * Kernel Map{i} (*為卷積運算) #### [激勵函數 activation function](https://cvfiasd.pixnet.net/blog/post/275774124-%E6%B7%B1%E5%BA%A6%E5%AD%B8%E7%BF%92%E6%BF%80%E5%8B%B5%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9) - 利用非線性方程式,解決非線性問題。 - 若不使用激勵函數,類神經網路即是以線性的方式組合運算,因為隱藏層以及輸出層皆是將上層之結果輸入,並以線性組合計算,作為這一層的輸出,使得輸出與輸入只存在著線性關係 - 現實中,所有問題皆屬於非線性問題,因此,若無使用非線性之激勵函數,則類神經網路訓練出之模型便失去意義。 - 分類 - softmax:值介於 [0,1] 之間,且機率總和等於 1,適合多分類使用。 ![](https://i.imgur.com/Azje757.png) - sigmoid:值介於 [0,1] 之間,且分布兩極化,大部分不是 0,就是 1,適合二分法。 ![](https://i.imgur.com/Fl1fdFV.png) ![](https://i.imgur.com/iFYfjxh.png) - Relu (Rectified Linear Units):忽略負值,介於 [0,∞] 之間。 - 使用Relu函數去掉負值,更能淬煉出物體的形狀 ![](https://i.imgur.com/9hYbNqW.png) - tanh:與sigmoid類似,但值介於[-1,1]之間,即傳導有負值。 ![](https://i.imgur.com/6PM4nI8.png) ![](https://i.imgur.com/RR7mFdd.png) ##### [卷積降維&升維](https://chih-sheng-huang821.medium.com/%E5%8D%B7%E7%A9%8D%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF-convolutional-neural-network-cnn-1-1%E5%8D%B7%E7%A9%8D%E8%A8%88%E7%AE%97%E5%9C%A8%E5%81%9A%E4%BB%80%E9%BA%BC-7d7ebfe34b8) ### 池化 - 將圖片資料量減少並保留重要資訊的方法,把原本的資料做一個最大化或是平均化的降維計算。 - ![](https://i.imgur.com/m9JLxvq.png) - 如下圖,原本8x8的圖片因為我取2x2的池化,所以會變成4x4。 - ![](https://i.imgur.com/tNjG58U.png) - 會根據feature map的結果去做pooling,然後得到的就是降維的特徵圖。此例為4x4的Pooling。 ### Flatten - 做完卷積運算和池化法後得到的特徵圖還是一個2-D的圖片,到全連接層前要先轉成1-D的陣列。(如果做完卷積或是池化後結構是1x1的feature map,此步驟可以省略) - ![](https://i.imgur.com/ks5grvy.png) ### 全連接層部份 - 等於一般神經網路 - Input node: Flatten後的結果,此例為18個nodes。 - Hidden layer: 1層 5個nodes - Output node: 2個輸出結果。 ### Parameter ![](https://i.imgur.com/3HVVxop.png) ![](https://i.imgur.com/hbQKi5C.jpg) 62是因為padding=valid(不補0)所以扣2,原本64 62->31因為pool_size=2*2 31->29因為padding=valid(不補0)所以扣2,原本64 29->14因為pool_size=2*2且padding=valid(不補0)所以會有一個消失29/2=14 14*14*32=6272 # Conference 1. https://chih-sheng-huang821.medium.com/%E5%8D%B7%E7%A9%8D%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF-convolutional-neural-network-cnn-cnn%E9%81%8B%E7%AE%97%E6%B5%81%E7%A8%8B-ecaec240a631 2. https://www.pyimagesearch.com/2018/12/31/keras-conv2d-and-convolutional-layers/ 3. https://ithelp.ithome.com.tw/articles/10191924 4. https://cs231n.github.io/convolutional-networks/ 5. https://chih-sheng-huang821.medium.com/%E5%8D%B7%E7%A9%8D%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF-convolutional-neural-network-cnn-%E5%8D%B7%E7%A9%8D%E8%A8%88%E7%AE%97%E4%B8%AD%E7%9A%84%E6%AD%A5%E4%BC%90-stride-%E5%92%8C%E5%A1%AB%E5%85%85-padding-94449e638e82 6. https://keras.io/api/optimizers/ 7. https://www.tensorflow.org/api_docs/python/tf/keras/optimizers 8. https://mropengate.blogspot.com/2017/02/deep-learning-role-of-activation.html 9. https://chih-sheng-huang821.medium.com/%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92-%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF-%E5%A4%9A%E5%B1%A4%E6%84%9F%E7%9F%A5%E6%A9%9F-multilayer-perceptron-mlp-%E5%90%AB%E8%A9%B3%E7%B4%B0%E6%8E%A8%E5%B0%8E-ee4f3d5d1b41 10. https://hackmd.io/@allen108108/rkn-oVGA4 11. https://chtseng.wordpress.com/2017/09/23/%E5%AD%B8%E7%BF%92%E4%BD%BF%E7%94%A8keras%E5%BB%BA%E7%AB%8B%E5%8D%B7%E7%A9%8D%E7%A5%9E%E7%B6%93%E7%B6%B2%E8%B7%AF/ 12. https://stackoverflow.com/questions/44608552/keras-cnn-model-parameters-calculation 13.

    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