Joseph Chu
    • 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 New
    • 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 Note Insights Versions and GitHub Sync 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Convolution Neural Network (CNN) ###### tags: `python` `Deep Learning` --- > >* **本文內容為“Tibame提升AI實作能力必備,深度學習TensorFlow基礎與應用”為主,版權為陳少君所有,本文僅做筆記用途,非商業用途** > >* **本篇圖片部分出自“Tibame提升AI實作能力必備,深度學習TensorFlow基礎與應用”課程內容講義** > --- # :memo: Introduction ## What is the difference between DNN and CNN? **優點1.** 同樣處理輸入32X32X3 image,輸出28X28X64 image DNN:因為要Flatten,所以運算需要(32X32X3)X(28X28X64),約等於154million CNN:經過Kernal(3X5X5X64)=4800 節省了32000次計算 其中, 32X32X3(WXHX(RGB)) 28X28X64(WXHX輸出channel) 3X5X5X64((RGB)XweightXweightX輸出channel) ![](https://i.imgur.com/0kTSrk1.png) **優點2.** Convolution可以解決平移不變性 結論: 因為圖片像素周圍皆有關聯性,DNN Flatten後做Fully connection(FC)會多做出一些無謂的特徵相關,因此CNN會比傳統DNN還要快上許多 # Convolution Layer ![](https://i.imgur.com/aT9Peif.png) Ref:[卷積神經網路(Convolutional neural network, CNN): 1×1卷積計算在做什麼](https://chih-sheng-huang821.medium.com/卷積神經網路-convolutional-neural-network-cnn-1-1卷積計算在做什麼-7d7ebfe34b8) ## Kernal kernel也可以稱作filter,類似用濾鏡的方式來把特稱取出 ![](https://i.imgur.com/OglowfQ.gif) ## Stride Stride為步長,即為方框在滑動時一次所需走之步數,常見為1 ## Padding 由於經過濾鏡後輸出層會縮小原尺寸,解決此問題之方法為Padding,在輸入尺寸周圍加0,此方法即為圖片邊緣模糊化 ![](https://i.imgur.com/iAIv2iH.jpg) ## Dimension Reduction ![](https://i.imgur.com/trTA3Wu.png) Ref:[卷積神經網路(Convolutional neural network, CNN): 1×1卷積計算在做什麼](https://chih-sheng-huang821.medium.com/卷積神經網路-convolutional-neural-network-cnn-1-1卷積計算在做什麼-7d7ebfe34b8) # Pooling Layer [What is the benefit of using average pooling rather than max pooling?](https://www.quora.com/What-is-the-benefit-of-using-average-pooling-rather-than-max-pooling) ## Max pooling & Average pooling 通常都用Max pooling # Fully Connected Layer(FC) 由於前段用卷積層或池化層減少其特徵運算,後段可以用FC來做特徵運算提高準度 # AlexNet 5個卷基層+3個全連接層 採用ReLU激活函數 # VGG 利用3X3 kernal代替AlexNet較大kernal # GoogleNet 設計了一個叫Inception的模塊 最後卷基層使用Gobal Average Pooling替換全連接層 # ResNet 殘差網路 # CNN應用 ## 單物件分類及定位 CNN有自動學習階層特徵(Hierarchical Features) CNN產生了很多延伸,像是R-CNN, Fast R-CNN, Faster R-CNN以及即時Yolo(You Only Look Once)等技術 ## 人臉辨識 找到人臉影像數據庫在Tensorflow中建置 # R-CNN(Regions with CNN) 1. 產生約2000個可能的區域(Region Proposals) 2. 將訓練好的CNN模型結果儲存起來 3. 用SVM(Support Vector Machine)分類器來區分是否為物體或背景 4. 經由Linear Regression來校正bounding box位置 R-CNN缺點: 1. 速度不夠快 2. 不容易作訓練 **Fast R-CNN** 使用ROIPooling,只用一次CNN並且為單一網路,較快也較易訓練 **Faster R-CNN** 直接從CNN的feature maps選出region proposals # Yolo 只需要對圖面做一次CNN便能判斷裡面物體類別跟位置 原理:將一張圖片切割成SXS個方格,每個方格以自己為中心去判斷B個bounding boxes包含物體的confidence score跟種類 confidence score = Pr(Object)\*IOU(ground truth) IOU:Intersection over Union(兩個bounding box交集) 當box有包含物件且IOU交集面積越大,分數就越高 最後取最高分數之bounding box ![](https://i.imgur.com/0yDluLE.jpg) ![](https://i.imgur.com/3IUs0h5.png) [pretrained YOLO object detection on Github](https://github.com/Garima13a/YOLO-Object-Detection) # Word Embedding 文字轉向量來解決深度學習指認數字不認文字串之問題 原理:將期望意義相近的字或詞有比較短的幾何距離,即為將某篇文章之每個特定單獨字都設定成000001,000010的樣子,而此方法也稱為One Hot Encoding Ex:King & Queen, Man & Woman, France & Germany ## word2vec 由google在2013推出的NLP工具 原理:一個當前詞預測前後詞(CBOW)或前後詞預測當前詞(SKIP-GRAM),因此相同部位的詞會相關 傳統DNN模型:CBOW(Continuous Bag-of-Words), Skip-Gram 但是此模型詞彙高達百萬種,因此才產生出Word2Vec來解決此問題 Word2Vec有四種模型: - Hierarchical Softmax CBOW - Hierarchical Softmax Skip-Gram - Negative Sampling CBOW - Negative Sampling Skip-Gram ## Gensim 優點: - Memory independence - Memory sharing - 多種向量空間算法之高效實現 - 支持多種數據結構 - 基於語義表示文檔相似度來查詢 Demo:[從汽車規格資料中挑出類似的機種(Make + Model)](https://github.com/zhlli1/Genism-word2vec) ## Skip-Gram Bag of words是最早嘗試把文字轉換成向量,以便建模和預測分析的方式 缺點: 1. 只關注詞出現的次數(Count),並沒有考慮其順序(Order)或上下文(Context) 2. Bag of Words是稀疏(Sparse)的,在真實應用大樣本的情況下,詞庫的數量級可能達到10000+,極為浪費資源。 skip-gram 模型的目標是由目標字找到上下文 Ex:“the quick brown fox jumps over the lazy dog” brown去猜\[quick,fox], quick去猜\[the, brown] 步驟: Step1. Build the corpus vocabulary Step2. Build a skip-gram\[(target, context), relevancy] generator Step3. Build the skip-gram model architecture Step4. Train the Model Step5. Get Word Embeddings Demo:[利用Skip-Gram比較兩句子的距離](https://www.kaggle.com/kesarianubhav/skipgram-word2vec) ## CBOW CBOW(Continous Bag of Words)是一個連續不斷的詞袋,裏頭有上下文以集目標詞,嘗試從上下文去猜測目標詞的機率,取決於窗口的寬度(context window width),上下文可能是一個字或一群字 Ex:“the quick brown fox jumps over the lazy dog” \[quick,fox]去猜brown, \[the, brown]去猜quick Skip-gram像是多個老師(周圍詞)在教一個學生(中心詞),中心詞經過嚴格訓練後向量結果會較為精準,但是時間會花比較久 CBOW像是多個學生(周圍詞)從一個老師(中心詞)學習知識,周圍詞學到多少要看是否能再從下一次同一個中心詞學習,學習速度快,但效果差 因此Skip-gram進行預測時間會多餘CBOW,但是Skip-gram會準確優於CBOW Demo:[Cbow.ipynb](https://github.com/nzw0301/kerasexamples/blob/master/CBoW.ipynb)

    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