qwer87511
    • 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
    • Make a copy
    • 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 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
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
    {%hackmd BJrTq20hE %} # ml lecture 1 - 2 Predicting the views of this channel - Introduction of ML / DL [slides](https://drive.google.com/file/d/12ri8Na55Z3gvqZginH4s9EGKo9v9a3Cl/view?usp=sharing) ## Training 1. Function with Unknow Parameters 2. Define **Loss** from Training Data 3. Optimization > ### Gradient Descent > 1. (Randomly) Pick an initial value $w^0$ (w can generalize to any parameter of L) > 2. Compute $$m={\partial L \over \partial w} | _{w=w^0}$$ > $w^1 \leftarrow w^0 - \eta m | _{w=w^0}$ (步伐大小由斜率和$\eta$決定,$\eta$: learning rate) > 3. Update $w$ iteratively (update all parameters to the general case) ## Linear Model $$ y = b + \sum_j w_jx_j $$ where $x_j$ are features and $w_j$ are weights ## Sophisticated Models - red curve = constant + sum of a set of blue line (piecewise) (hard sigmoid) ![](https://github.com/qwer87511/HackMD/blob/master/ml/xZ3TMWQ.png?raw=true =300x) - Sigmoid (s型的function) (用很多藍直線組合出一個平滑(藍)曲線) $$ sigmoid(b+wx_1) = {1 \over 1 + e^{-(b+wx_1)}} $$ - a blue line $$ y = c \cdot sigmoid(b+wx_1) $$ - ![](https://github.com/qwer87511/HackMD/blob/master/ml/DyjsNRt.png?raw=true =300x) - a red curve (with 1 feature) ($b+wx_1$放到sigmoid裡面) $$ y = \sum_i c_i \cdot sigmoid(b_i + w_ix_1) $$ - new model (with j features) (put linear model into sigmoid) (此處僅將linear model平滑化) (只看i和只看j比較好理解) (i是將linear model分割成piecewise functions所需的藍線個數(自己決定),即需要幾個sigmoid functions來近似它, j是features的個數) $$ y = b + \sum_i c_i \cdot sigmoid(b_i + \sum_j w_{ij}x_j) $$ - let i = 3 be no. of features, j = 3 be no. of sigmoid for example let $r_i$ be $b_i + \sum_j w_{ij}x_j$ (即上式sigmoid的裡面) so that $r_1 = b_1 + w_{11}x_1 + w_{12}x_2 + w_{13}x_3$ (即linear model做piecewise的第一個藍線) so that $$ \begin{bmatrix} r_1 \\ r_2 \\ r_3 \\ \end{bmatrix}= \begin{bmatrix} b_1 \\ b_2 \\ b_3 \\ \end{bmatrix}+ \begin{bmatrix} w_{11} & w_{12} & w_{13} \\ w_{21} & w_{22} & w_{23} \\ w_{31} & w_{32} & w_{33} \\ \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ \end{bmatrix} $$ $\to r=b+Wx$ let $a_i = sigmoid(r_i) = {1 \over 1 + e^{-r_i}}$ $\to a = \sigma (r)$ ($\sigma$ is $sigmoid$ function to vector) $y = b + c_1a_1 + c_2a_2 + c_3a_3$ $\to y = b + c^Ta$ ![](https://github.com/qwer87511/HackMD/blob/master/ml/tWylEtp.png?raw=true =300x) - $y = b + c^T \sigma (b + Wx)$ (前面的b是常數後面是向量) ## Back to ML Framework - $$ \theta = \begin{bmatrix} \theta_1 \\ \theta_2 \\ \vdots \\ \end{bmatrix}= \begin{bmatrix} columns\;of\;W \\ b \\ c^T \\ b \\ \end{bmatrix} $$ (所有參數一律統稱$\theta$) - Back to ML Framework - $\theta$ 做為新的features再做一次[Training steps](##Training) - Define loss function $L(\theta)$ - Optimization of New Model - $\theta^* = arg\;\displaystyle\min_\theta\;L$ - (Randomly) Pick initial values $\theta^*$ - gradient $$ g = \begin{bmatrix} \ {\partial L \over \partial \theta_1} | _{\theta=\theta^0} \\ \ {\partial L \over \partial \theta_2} | _{\theta=\theta^0} \\ \ \vdots \\ \end{bmatrix} $$ (把所有參數都拿去對L做微分) - $g = \nabla L(\theta^0)$ - $\theta^1 \leftarrow \theta^0 - \eta g$ (重覆到不想做為止) - split the data into multiple batches and calculate gradients separately(p. 44) - $g = \nabla L^1(\theta^0)$ (by batch 1), and update $\theta^1$, ... - 1 **epoch** = see all the batches once - Sigmoid $\to$ ReLU $$y = b + \sum_i c_i sigmoid(b_i + \sum_j w_{ij}x_j)$$ $$\to y = b + \sum_{2i} c_i max(0, b_i + \sum_j w_{ij}x_j)$$ - Back to ML framework $a=\sigma(b+Wx)$, 算出來的**a**再作為input, 再放進一組新的function(具不同參數), 得到**a'**, 可以反覆做多次 ![](https://github.com/qwer87511/HackMD/blob/master/ml/uXOh1NU.png?raw=true =300x) - 一個activation function稱作 Neuron - 每一層稱作 hidden layer - 很多層合起來稱作 Neural Network - many layers means **Deep** $\to$ Deep learning - Better on traning data, worse on unseen data $\to$ **Overfitting** ## Terminologies - sophisticated - piecewise 分段的 - rectified Linear Unit (ReLU) (修正線性單元) (用2個可以合成一個hard sigmoid) (p. 47) (效果比sigmoid好) - activation function (激勵函式) (包含sigmoid, ReLU) - epoch 時期 - neuron 神經元 - neural Network ###### tags: `ml`

    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