Yun-Tao Chen
    • 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
    • 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
  • 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # RNN 筆記 - 基礎架構 Ref 吳尚鴻教授上課影片 from Youtube: https://www.youtube.com/watch?v=2btuy_-Fw3c&list=PLlPcwHqLqJDkVO0zHMqswX1jA9Xw7OSOK Ref LaTeX Math Symbols: http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html 本篇主要透過數學表達式,來探討 RNN 之架構 ## Vanilla RNN ### RNN Dataset Dataset: X $= \{ {X^{(n)}} \}_n \in \mathbb{R}^{N \times (D,K) \times T}$ - ${X^{(n)}} = \{(x^{(n,t)},y^{(n,t)}) \}_t$ a ==sequence==, where the superscript $n$ can be ommited for spimplicy 很多的 x,y pair - $n$ 代表**第n個** data point - 資料點 x 維度是 $D$ - 資料點 y 維度是 $T$ - $T$ 代表時間維度,稱為 horizon - $T$ is call the horizon and may be different between ${x^{(n)}}$ and ${y^{(n)}}$ 注意: x 跟 y 的 horizon 不一定會相同,可能某些時間點才會同時出現 x 跟 y,而某些時間點只有 x - **$y^{(t)}$ depends on ${x^{(1)}, x^{(2)}, ..., x^{(t)} }$** ### RNN Architecture - Output ${a^{(L,t)}}$ depends on hidden activations **${a^{(k,t)}} = act(z^{(k,t)}) \\ = act(U^{(k)}a^{(k,t-1)}+W^{(k)}a^{(k-1,t)})$** k 代表第 k 層 t 代表時間點 對於第 k 層的神經元過 activation a() 函式數值的影響,來自於兩個東西: 一個是上一個時間點同為第 k 層神經元所傳送過來的數值 + 這個時間點,前一層 (k-1) 層傳送過來的數值 - p.s. 這裏的數學式省略沒寫 Bias 實際上還要加上 Bias 才完整 ![](https://i.imgur.com/tCyDMX8.png) - $a{(\cdot,t)}$ summerizes ${x^{(t)}, x^{(t-1)}, ..., x^{(1)} }$ - Earlier points are less important 公式深入探討: ${a^{(k,t)}} = act(z^{(k,t)}) \\ = act(U^{(k)}a^{(k,t-1)}+W^{(k)}a^{(k-1,t)})$ - U 跟 W 函數當中,並沒有時間的維度,因此 **Weights are ==shared== across time instances** 不隨著時間改變,U 跟 W 訓練出來後,在所有時間點可以共用 - Assumes that the "transition functions" are time invariant RNN 假設 transition of U, W 不會隨著時間改變 - Our goal is to learn $U^{(k)}$'s and $W^{(k)}$'s for $k=1,2,3,...,L$ RNNs have Memory ### RNN and be folded in time 右圖: 把所有的時間點都畫一份 左圖: 把右圖的表達畫成 fold 版本 ![](https://i.imgur.com/orvtqE7.png) 從左圖 folding 的圖看,就可以觀察出,上一個時間點的 a 很明顯的需要先"記下來"放在 Memory 裡面,等待給下一個時間點來使用 ## RNN 的變形 ### 從 Input Output 來看 ![](https://i.imgur.com/IHp2BJw.png) 例子: - One to Many -> Image Captioning input: 一張圖 output: 多個文字來描述這張圖片 ![](https://i.imgur.com/Zyoiitf.png) - Many to One -> **Sentiment Analysis** input: 一個電影的 Review Output: 正評還是負評 ![](https://i.imgur.com/8jY32aX.png) 如果這個例子使用 word vector 單純去 encode 去做的話,可能會被 Reward wins 等字誤導為正面很多的評價,實際上這句是個諷刺的獎項,要從前後文來推敲意思! - Many to Many (Synced): Video Keyframe Tagging input: 影片 output: 一系列的 tag 點出哪些時間點發球出去 ![](https://i.imgur.com/I0KkfCS.png) - Many to Many (Unsynced): Machine Translation input: 中文原文 output: 英文翻譯 ![](https://i.imgur.com/axA3tg2.png) 中英文並非一對一的關係 中文字必須要看到若干個字之後,才能翻譯出正確的一個英文單字 這樣的案例又稱為==sequence to sequence== learning ### Bidirectional RNNs 原本的 RNN ${a^{(k,t)}} = act(U^{(k)}a^{(k,t-1)}+W^{(k)}a^{(k-1,t)})$ ![](https://i.imgur.com/zw0gdLP.png) 第 k 層的除了看過去時間點傳來的參數,也看未來時間點一路傳過來的參數 以網球比賽影片為例: 我們可以多取一些獲勝球員的精彩畫面,來訓練 RNN 這樣的訓練之下的 Model 就可以來預測看哪個球員最後會贏! ### Recursize RNNs 基本 RNN 的問題: 越早發生的時間點影響力越小,要離現在時間點越近的weight影響力才會越大,這樣的架構下,對於文意判讀會有問題 NLP 裡面的例子 Given movie review: - create a parse tree 來 parse sentence - define Neural Network on the tree ![](https://i.imgur.com/80NmqSk.png) Tree 裡面的定義了字跟字之間的關係 U 跟 W 可以是 invariant 的: 在每一個 merged point 都可以是不變的,讓 machine 在每一個點都使用同樣一組 U 跟 W 來 merge 出新的 root 這樣的 RNN 裡面每一個 substructure 都是 recursively shared!

    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