PyCon Taiwan
      • 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

      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
    • 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 Help
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
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

    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
    # Deep Learning for NLP: PyTorch vs Tensorflow - Elvis Saravia {%hackmd DR5p-QuLTwylJM8bYjJp1Q %} * 簡報: [Deep Learning for NLP \(PyCon\) \- Google 簡報](https://docs.google.com/presentation/d/1cf2H1qMvP1rdKUF5000ifOIRv1_b0bvj0ZTVL7-RaVE/edit#slide=id.p) * [Deep Learning for NLP: PyTorch vs Tensorflow](https://paper.dropbox.com/doc/Deep-Learning-for-NLP-PyTorch-vs-Tensorflow-uLd5vxnoJ78Dl3WNqO6MG) 1. About Emotions -挑戰:沒有統一定義的情緒 # 選擇 framework - pytorch - 2016 - 動態有向圖 (DAG) - 執行時偵錯 - 需要看蠻多手冊說明 - 需要手動來跨平台 - 不支援分散式學習 - 資料平行化簡單 - 幫你包到好 - 容易上手 - tensorflow - 2015 - 靜態有向圖 (DAG) - 開始運算前就要決定(先決定架構,才做運算) - 使用特定的工具偵錯 - 跨平台很簡單 - 支援分散式學習 - 資料平行化較難 - 很多事情要手動處理 - 適合產品化 - 講者是研究者,想快速做實驗,所以選pytorch # 資料 - 如果句子中的hash tag有情緒就能用來當tag - 講者推薦這個dataset: 英文和印尼文https://github.com/huseinzol05/NLP-Dataset/ ## 資料轉換 需要先處理資料 - Bag of words(詞袋) - n-grams - Character embeddings - Word embeddings ## Bag of Words 將句子中每個字代表的情緒取出,只記錄該句子包含哪些情緒 - 句子有出現的詞 -> 1, 沒出現 -> 0 - 但無法保留詞序、無法處理否定句: Good, not bad跟Bad, not good組成字相同所以vector相同,但意思完全相反 ## one-hot encoding 使用 one-hot encoding 來保留句子中單字的順序 - 無法辨識相同意思的句子 ## Word Embeddings - 用機器學習將詞轉為向量 - Continuous Bag of Words(CBOW)[https://zh.wikipedia.org/wiki/Word2vec#Skip-grams%E5%92%8CCBOW] - 使用預先訓練過的model(pre-trained model)或自行訓練model ## 如何自行訓練 word embedding model 1. 給每個詞一個 id 2. X 是 Y 前後的詞 * e.g. feel(X) awful(Y) about(X) 3. Train! - 使用 tensorflow - 較關注於架構 - 存模型的方式較彈性 - 使用 pytorch - 只需要知道input 與 output,不太需要知道內部參數的細節(implicit) # 訓練 - 為什麼使用 LSTM - 句子中的字與該字之前的用字有關 - 需要保留順序 - 句子長度不同 ## 步驟 - 分割資料,驗證,測試 - 將句子切成字 - 用 word2vec 轉換 - RNN 處理 (padding很重要) - Bucketing比padding更有效率。可參考 https://goo.gl/h6Z9kU # 結果 - 準確率 89.9% - TensorFlow 和 PyTorch 的訓練時間和結果差不多 - love與joy的情緒不容易分辨 ## 延伸 - 試試 CNN models - 使用不同資料來源,如演講等等 - 使用包含錄音、影像的文字資料 ## 結論 - PyTorch 建立 models 比較簡單 - 使用 Tensorflow 可以學到更多底層 - Data 是效能瓶頸 # Q&A - 你是手動還是自動產生每個字的情緒token? - 是自動的,用字與字在同一份文件中出現的頻率 - 利用同義詞 - 你如何處理中文字等等不同語言? - 只要有字庫就可以處理,但是我沒試過中文跟日文 - 就我所知,tensorflow可以保存model到檔案,請問pytorch也可以嗎? - 可以 [ONNX](https://onnx.ai/supported-tools) ###### tags: `pycontw2018`

    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