吳鎧丞
    • 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
    2023 中原電機知識馬拉松競賽 === # 1. 機器學習中的演算法 ## 1.1 線性迴歸(Linear Regression): Date:2023/05/23 >線性迴歸屬於++監督式學習++,可以拆分成「線性」和「迴歸」來了解,前者為模型類型,稱「線性模型」,後者為問題類型,稱「迴歸問題」。線性模型能用大家熟悉的y = ax + b 來理解,而迴歸問題是一種統計方法,用於表示相依變數和獨立變數之間的關係,通常相依變數會隨著獨立變數變化,所以結合上述兩者能得出++線性迴歸++是用來預測一個連續的值,目標是想找一條直線可以逼近真實的資料。 #待修改 ### 1.1.1 訓練步驟: >**STEP1** : 求出模型參數 W >**STEP2** : 損失函數最小化(使真實值與預測值的誤差總和最小化) >**STEP3** : 梯度下降 ### 1.1.2 線性迴歸**python**應用範例: #### **範例 1:** **使用套件** ```python= import matplotlib.pyplot as plt from sklearn import linear_model from sklearn.datasets import make_regression from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error, r2_score ``` **生成資料並利用matplotlib顯示資料分布** ```python=+ X,Y = make_regression(n_samples=200, n_features=1, noise=50, random_state =42) #畫出網格線 plt.grid() #畫出所有資料 plt.scatter(X,Y) ``` >![](https://hackmd.io/_uploads/BkH60PiS3.png) > **利用train_test_split進行資料分割,分成訓練集70%測試集30%** ```python=+ X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.3, random_state=0) ``` **建立模型和訓練模型,並顯示預測的直線** ``` python=+ #建立模型 model = linear_model.LinearRegression() #訓練模型 model.fit(X_train, Y_train) #畫出網格線 plt.grid() #劃出訓練集資料 plt.scatter(X_train, Y_train, color='blue') #畫出訓練好的直線 plt.plot(X_train, model.predict(X_train),color='red',linewidth=1) plt.show() ``` >![](https://hackmd.io/_uploads/SJNuxOjr2.png) **計算直線方程式** ```python=+ #計算截距 W0 = model.intercept_ #計算特徵係數 W1 = model.coef_ print("y = ",W0," + ",W1,"* x") ``` y = 4.996594357444268 + [87.22045235] * x ```python=+ #使用訓練好的模型預測測試集中的Y Y_pred = model.predict(X_test) #畫出測試集資料 plt.scatter(X_test, Y_test, color='red') #畫出網格線 plt.grid() #畫出預測Y與測試集X的關係 plt.plot(X_test, Y_pred,color='blue',linewidth=1) plt.show()``` ![](https://hackmd.io/_uploads/HkuVXOiS2.png) **使用訓練好的模型分別帶回訓練集和測試集計算其準確率** ```python=+ train_score = model.score(X_train,Y_train) test_score = model.score(X_test, Y_test) print('train_score: '+ str(train_score*100) + '%') print('test_score: ' + str(test_score*100) + '%') ``` train_score: 71.69772873715996% test_score: 70.39215598647498% ```python=+ # The mean squared error #利用mse計算預測值與誤差值的總和(越小越好) print("Mean squared error: %.2f" % mean_squared_error(Y_test, Y_pred)) #The coefficient of determination: 1 is perfect prediction #利用r2_score判斷迴歸模型的解釋力(越接近於 1 最好) print("Coefficient of determination: %.2f" % r2_score(Y_test, Y_pred)) ``` Mean squared error: 2601.96 Coefficient of determination: 0.70 ### 1.1.3 參考資料: * https://zhuanlan.zhihu.com/p/80887841 * https://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html * https://chwang12341.medium.com/machine-learning-linear-regression%E8%BF%B4%E6%AD%B8%E6%A8%A1%E5%9E%8B-%E5%BC%B7%E5%A4%A7%E7%9A%84sklearn-%E7%B0%A1%E5%96%AE%E7%B7%9A%E6%80%A7%E8%BF%B4%E6%AD%B8%E6%A8%A1%E5%9E%8B-%E5%A4%9A%E9%A0%85%E5%BC%8F%E8%BF%B4%E6%AD%B8%E6%A8%A1%E5%9E%8B-%E5%A4%9A%E5%85%83%E8%BF%B4%E6%AD%B8%E6%A8%A1%E5%9E%8B-%E5%AE%8C%E6%95%B4%E5%AF%A6%E4%BD%9C%E6%95%99%E5%AD%B8-984c73ab5e05 ## 1.2 邏輯迴歸(Logistic Regression): 邏輯迴歸屬於監督式學習,用於二分類問題,其判斷方式是用線性迴歸的輸出來進行分類,用一個簡單的思維來描述,就是將直角坐標系上的任一點帶入迴歸線,利用輸出值>=0以及<0將結果分成兩類,而實際上在邏輯迴歸運作時是在輸出迴歸線後添加了sigmoid的函數才能使輸出具有分類效果。 * sigmoid函數: ![sigmoid函數](https://hackmd.io/_uploads/r1PMrMAr3.png =400x) ### 1.2.1 邏輯迴歸**python**應用範例: ## 1.3 單純貝氏(Naive Bayes): ## 1.4 決策樹(Decision Tree): ## 1.5 隨機森林(Random Forest): ## 1.6 支援向量機(Support Vector Machine): ## 1.7 GDBT(Gradient Boosting Trees): # 2. 意外的小插曲: ## 2.1 VLSI LAB 8×8 SRAM 64BITS: ### 2.1.1 前言: 這是在學校上的VLSI系統設計實習的期末作業,老師要求我們製作出一個8×8或是8×6的sram。這項作業是與同一堂課的一位朋友共同完成。 ### 2.1.2 繳交項目 * 1-bit SRAM 電路圖、sp檔、模擬結果 * 8×8-bits SRAM 電路圖、sp檔、模擬結果 * Precharge 電路圖、sp檔、模擬結果 * Decoder 電路圖、sp檔、模擬結果 * Senseamp 電路圖、sp檔、模擬結果 * Outbuffer 電路圖、sp檔、模擬結果 * Write Control 電路圖、sp檔、模擬結果 ### 2.1.2 What is sram ? 靜態隨機存取記憶體**sram**(Static random-access memory)是一種靜態、揮發性、隨機存取的半導體記憶體,且具有讀寫操作。 sram是一種靜態記憶體,這表示他不需要定期整理,而就資料的保存持久性,只要維持在通電的情況下,儲存在裡面的資料就會一直保留。 * 完整 sram 的結構 ![](https://hackmd.io/_uploads/HJnihK6v3.png) ### 2.1.3 1-bit sram 的電路結構和 mos 尺寸 * mos尺寸參照 SRAM Ref * PMOS 4u/340n * NMOS 2.5u/340n ![](https://hackmd.io/_uploads/Skg_fKTPh.png) * 1-bit sram input ![](https://hackmd.io/_uploads/rJx5XY6vh.png =200x) * 1-bit sram 電路模擬結果 ![](https://hackmd.io/_uploads/r1qINKpvn.png) ### 2.1.4 8×8 bit sram結構 * 完整 8×8 bit sram結構 * Precharge * Row_Decoder * Col_Decoder * Col_Select * Write_Control * SenseAmplifier * OutBuffer ![](https://hackmd.io/_uploads/ryVKaFaDn.png) ### 2.1.5 Precharge 電路及功能 Pre-charge電路確保在W/R動作時BL及BLB位於高電位。W/R操作前,Pre-charge會先將BL及BLB置為VDD,且當Write為低電位時,Senseam及OutputBufferr透過CLK Posedge將WL資料輸出。 ![](https://hackmd.io/_uploads/BkEWJc6P3.png) * Precharge Layout DRC ![](https://hackmd.io/_uploads/SJPZlcpvn.png) * PreCharge Layout LVS ![](https://hackmd.io/_uploads/Syx4lcTw2.png) ### 2.1.6 Write Control 電路及功能 透過CLK將資料輸入至 BL 及 BLB 中使 Cell儲存這些資料。 ![](https://hackmd.io/_uploads/ByXG-q6P2.png) * Write Control Layout DRC ![](https://hackmd.io/_uploads/ByDv-c6w2.png) * Write Control Layout LVS ![](https://hackmd.io/_uploads/rJGt-9aP2.png) ### 2.1.7 Decoder 電路及功能 3 to 8 Decoder 由三個 inverter 及 8 個 AND Gate 組成,使輸入 3 bit 能轉換成 8 bit 的控制訊號,用以選擇 Row 及 Column 欲操作的 SRAM Cell。 ![](https://hackmd.io/_uploads/HJ6Az9aw2.png) * Decoder 所需的 AND Layout DRC ![](https://hackmd.io/_uploads/S12hN56v3.png) * Decoder 所需的 AND Layout LVS ![](https://hackmd.io/_uploads/rybaN5Twn.png) ### 2.1.8 SenseAmplifier 電路及功能 用於在Read Operation時,由於讀取前Precharge會先將BL及BLB充電至高電位,當Cell內部存0時,BL會緩慢下降,Senseamp透過差動放大器比較BL及BLB差值,能更快的輸出正確的電位。 ![](https://hackmd.io/_uploads/HkKrBqawh.png) ### 2.1.9 OutputBuffer 電路及功能 用以調整不同CLK時脈的輸出速度。 ![](https://hackmd.io/_uploads/BkHYS96vn.png) * OutputBuffer Layout DRC ![](https://hackmd.io/_uploads/H1bSLqTDh.png) * OutputBuffer Layout LVS ![](https://hackmd.io/_uploads/ryISL56wh.png) ### 2.1.10 Final 64 bits Sram電路 * 64-bits SRAM 組成 1. Precharge*8 1. ROW_Decoder*1 1. COL_Decoder*1 1. COL_Select*8 1. Write_Control*8 1. SenseAmplifier*8 1. OutputBuffer*8 1. Cell*64 ![](https://hackmd.io/_uploads/HkadU9Tvn.png) ## 2.2 人工智慧於電網之應用 ### 2.2.1

    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