臺中一中39th電研社教學
      • 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
    --- title: AI人工智慧初探 slideOptions: theme: blood transistion: 'slide' --- AI人工智慧初探 === >[name=張皓凱、陳睿倬][time=Fed 25,2022] ###### tags: `AI` `tcirc` `社課` `臺中一中電研社` --- 第七節社課 === [TOC] --- ## 電研社 講義都會公告在社網上 [社網:tcirc.tw](https://tcirc.tw/) [IG:tcirc_39th](https://www.instagram.com/tcirc_39th/) ![ig QRcode](https://i.imgur.com/4hyS6GM.png) [online judge:judge.tcirc.tw](https://judge.tcirc.tw/) <!--理論--> --- ## 什麼是人工智慧 ---- AI(artificial intelligence)指的是以「人工」方式撰寫程式,來達成模擬人類「智慧」的目的。 人工:由人設計、製作、創造 智慧:聽音辨讀、視覺辨識、推理決策、理解學習、移動、動作控制 ---- ### 應用 自然語言生成、語音識別、虛擬助理、可能認識的人、youtube廣告、導航路徑... --- ## 人工智慧簡史 ---- 1956年-達特矛斯學院的約翰·麥卡錫 (J. McCarthy) 發起了一場活動:夏季人工智慧研究計劃。誕生了人工智慧這個名詞,這場活動也被後人視為人工智慧革命的開端。 70年代-由於大家不再看好人工智慧,所以就進入了寒冬期,被稱為第一次人工智慧泡沫。 ---- 80年代-出現機器學習 1987年-因為機器學習仰賴大量的訓練資料和龐大的運算能力,迎來了第二次人工智慧泡沫。 ---- 2006年-類神經網路的支持者,傑佛瑞·辛頓 (Geoffrey Hinton)提出了新的類神經網路訓練方法,並以深度學習之名重新包裝,Hinton 也因此被譽為深度學習之父。 2017年-AlphaGo戰勝世界第一棋士柯潔 --- ## 人工智慧分類 ![](https://i.imgur.com/Ggr4dKy.png) [圖源:hackernoon](https://hackernoon.com/difference-between-artificial-intelligence-machine-learning-and-deep-learning-1pcv3zeg) ---- ### 人工智慧不包含機器學習的部分 **基於規則系統(rule-based system)** 大量的if else,e.g.看到紅燈停,綠燈行 缺點:必須完全依賴人類定義各種條件所對應到的結果 ---- ### ML vs. DL ![](https://i.imgur.com/3cdzKKi.png) [圖源:makerpro](https://makerpro.cc/2019/05/introduction-to-ai/) 最主要差異在於特徵是否需要人工提取 ---- ### 機器學習&深度學習 接下來這一節所有的內容都屬於機器學習,若同時為深度學習的內容將在後面標記(DL) ---- 機器學習分為四種:監督式學習、半監督式學習、無監督學習、強化式學習 監督:給予標記 ---- * 監督式學習:給機器各1000張蘋果和橘子的照片(全都有「標記」)後,詢問機器新的一張照片中是蘋果還是橘子,e.g.類神經網路(DL)、K-近鄰演算法、決策樹 * 半監督式學習:給機器各1000張蘋果和橘子的照片(其中只有各100張有「標記」)後,詢問機器新的一張照片中是蘋果還是橘子 ---- * 無監督學習:給機器各1000張蘋果和橘子的照片(全無「標記」)後詢問機器新的一張照片中是**哪一種**,e.g.生成對抗網路(DL)、K-平均演算法 * 強化式學習:給機器各1000張蘋果和橘子的照片(全無「標記」),但每次程式做出判斷後會告訴程式判斷是否正確,e.g.蒙特卡洛學習、自動小恐龍 --- ## K-近鄰演算法 - K Nearest Neighbors, Knn - ML - 監督式學習 ---- ### why knn 第一類:(2, 3), (1, 5), (3, 2), (6, 3), (4, 4), (4, 7), (8, 7), (3, 9), (10, 2), (11, 13) 第二類:(14, 10), (13, 8), (14, 6), (11, 5), (13, 3), (11, 9), (15, 4) 第三類:(2, 14), (3, 12), (5, 13), (4, 15), (8, 15), (6, 12), (9, 13), (8, 11), (5, 10), (7, 9), (9, 9), (2, 4), (12, 12), (11, 11), (13, 14) 問:(7, 5)屬於? ---- ![](https://i.imgur.com/TIgiB6G.png) ---- ### knn 步驟 (k-d Tree) :arrow_right: 選擇k :arrow_right: 算所有距離 :arrow_right: 排序 :arrow_right: 選擇前k個 :arrow_right: 投票 :arrow_right: 決定 ---- ### k要多少 k大-underfit k剛好-好棒棒 k小-overfit ---- ### 簡單小實做 https://colab.research.google.com/drive/1fGIMsRyp7XjL6lX9nndfKC4uCs35LLxt?usp=sharing --- ## 類神經網路 - ann(Artificial Neural Network), mlp(Multilayer Perceptron), **dnn**(Deep Neural Network)、nn結尾的 - DL - 監督式學習 ---- ### why dnn ![](https://i.imgur.com/jBoeHGe.png) 黑(0)---->白(255) ---- ![](https://i.imgur.com/W7PSyQB.jpg) ---- ### 基本類神經網路 輸入層:arrow_right:隱藏層:arrow_right:輸出層:arrow_right:計算loss:arrow_right:用優化器反向傳播修正:arrow_right:依epocs次數再來一次 ---- #### 輸入、隱藏、輸出層 ---- 每條線都有一個權重(weight) 每個隱藏層節點都有一個bias 每個隱藏層都有一個activation function ---- ![](https://i.imgur.com/6dI4v7M.png) [圖片來源:tipco](https://www.tibco.com/reference-center/what-is-a-neural-network) ---- ![](https://i.imgur.com/ncjZQxT.png) [圖片來源:itzone](https://itzone.com.vn/en/article/a-brief-history-of-some-names-in-machine-learning-deep-learning/) ---- ![](https://i.imgur.com/HwbzDFH.png) [圖片來源:medium](https://medium.com/%E6%B7%B1%E6%80%9D%E5%BF%83%E6%80%9D/ml08-activation-function-%E6%98%AF%E4%BB%80%E9%BA%BC-15ec78fa1ce4) ---- #### loss、優化器(optimizer)、反向傳播 ---- loss-用於評估模型好壞 優化器-決定weight、及bias的調整量 反向傳播-將須調整的量傳回上一節點 ![](https://i.imgur.com/LTykDAy.png) [圖片來源:tommy huang](https://chih-sheng-huang821.medium.com/%E6%A9%9F%E5%99%A8-%E6%B7%B1%E5%BA%A6%E5%AD%B8%E7%BF%92-%E5%9F%BA%E7%A4%8E%E4%BB%8B%E7%B4%B9-%E6%90%8D%E5%A4%B1%E5%87%BD%E6%95%B8-loss-function-2dcac5ebb6cb) ---- ![](https://i.imgur.com/CrUBayY.png) [圖片來源:Hung-yi Lee](https://www.youtube.com/watch?v=xki61j7z-30) ---- ![](https://i.imgur.com/mzF13YF.png) [圖片來源:paperspaceBlog](https://blog.paperspace.com/intro-to-optimization-in-deep-learning-gradient-descent/) ---- ### ann vs mlp vs dnn - ann:剛才講的 - mlp:剛剛講的但只有全部連結層 - dnn:很多層(10up) ---- ### 視覺化 https://playground.tensorflow.org/ ---- ![](https://i.imgur.com/98VZrt2.png) --- ## 生成對抗網路 - GAN,~~deepfake~~ - DL - 無監督式學習 ---- 先來玩玩看 https://affinelayer.com/pixsrv/ ---- GAN是有一個Generator(生成器)與Discriminator(檢查者),可以想像成作假鈔的人與辨認假鈔的警察。訓練時,Generator 為不斷想辦法騙過 Discriminator,而Discriminator 會努力的去判別,雙方會同時不斷的進步成長。 ---- ![](https://i.imgur.com/aBoBaOx.png) --- <!--實作--> ## 軟體教學及簡介 ### google colab google colab 是一個線上的python直譯器,使用方式和 jupyter notebook相同。google colab 優點在於有網路和google帳號便可使用,且有免費的GPU可以使用,降低硬體的規格需求。 [google colab 官方使用說明](https://colab.research.google.com/notebooks/welcome.ipynb?hl=zh-tw) ---- ### keras 使用python編寫的神經網路API,這學期會藉由tensorflow模組使用,由google維護。我們可以藉由keras裡已完成的機器學習演算法程式,輕鬆寫出一個深度神經網路 [Keras API](https://keras.io/) ---- ### tensorflow tensorflow是一個開源機器學習的python模組,裡面裝著已寫好的深度學習演算法,也包含上面的keras [Tensorflow](https://www.tensorflow.org/?hl=zh-tw) --- ## data preprocess ### dataset 數據集 當我們要讓一個程式學習時,我們需要將大量的資料輸入,讓此人工智慧學習後能夠正常的運作,正確預測未來或分辨事物。 數據集越多越好,但我們也必須注意資料的完整性,篩選並適時汰除特殊資料,讓機器不會因這些特殊資料而產生變形。 ---- ### train, valid ,test data 通常我們會將資料分成三個部分: 訓練資料、驗證資料、測試資料 * 訓練資料: 和字面上的意思一樣,就是給機器學習的資料。就像我們在學校使用的課本 * 驗證資料: 驗證資料可以使我們確認一個機器在學習完後的狀況,利用一些指標來確認此機器是否能達到我們的期待,並調整某些參數。可以把它想像成模擬考,來確認哪些學生程度不錯。驗證資料通常是取學習資料裡的10% * 測試資料: 此資料是對最終的模型進行評估,就像段考。 假如我們手中有一資料集,我們有許多方法來將它分成上述三種資料 * 截留驗證法: 就是將資料以一定比例分配,例如: 2:1, 4:1...等。這種分法通常是對數據分常多的時候使用。 * K折交叉驗證: 將資料集分成K個,使用其中一個當作學習資料,剩餘K-1個當作測試資料。重複此方法K次。最終把所有結果平均後評估此模型。 [![](https://i.imgur.com/BoLuSuc.png)](https://miro.medium.com/max/1400/0*3o5Iwyak7m9B2aGa.png) [圖源](https://www.google.com/url?sa=i&url=https%3A%2F%2Fchwang12341.medium.com%2Fmachine-learning-%25E4%25BA%25A4%25E5%258F%2589%25E9%25A9%2597%25E8%25AD%2589-cross-validation-%25E6%2589%25BE%25E5%2588%25B0knn%25E4%25B8%25AD%25E9%2581%25A9%25E5%2590%2588%25E7%259A%2584k%25E5%2580%25BC-scikit-learn%25E4%25B8%2580%25E6%25AD%25A5%25E4%25B8%2580%25E6%25AD%25A5%25E5%25AF%25A6%25E4%25BD%259C%25E6%2595%2599%25E5%25AD%25B8-4109bf470340%3Freadmore%3D1%26source%3Dfollow_footer---------4----------------------------&psig=AOvVaw3l7AmSUw0BpBVXX7I_UYZH&ust=1645542528087000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCLDfnciKkfYCFQAAAAAdAAAAABAK) ---- ### 標準化 資料標準化有助於我們修正一些稍微極端的資料。資料標準化能提升梯度的收斂,使模型變得穩定。學習後的模型準確率也會高很多。 ---- 數據標準化有許多種作法,這裡介紹兩種 - 分數標準化: Z = X - u/a u: 平均數, a: 標準差 [標準差](https://zh.wikipedia.org/wiki/%E6%A8%99%E6%BA%96%E5%B7%AE#%E5%9F%BA%E6%9C%AC%E5%AE%9A%E7%BE%A9) - 最小最大值標準化: Z = X - Xm/ XM - Xm Xm: 數據裡的最小值 XM: 數據裡的最大值 (此算法能使數據範圍所小至0~1區間,使資料不會過大,消耗運算資源) --- ## Sequential model - dense layer 當我們要建立一個深度學習模型時,會有一個輸入層,一個輸出層,和好幾個隱藏層,而我們會將這些層一個一個疊出來。 一開始我們會先建立一個空模型Sequential模型。這個模型從tf.keras.models匯入。Sequential是最基本的深度學習模型,適用許多於數據集。 ```python= from tensorflow.keras.models import Sequential model = keras.Sequential() ``` ---- 接著,我們要把隱藏層加上去。要加隱藏層上去,必須從tf.keras.layers匯入Dense。在設定一個隱藏層時,要設定隱藏層的參數: 節點(輸往下一層的資料量)、激活函數 ```python= from tensorflow.keras.layers import Dense model.add(Dense(節點數, activation = '激活函數')) ``` 記得,當你在加入第一層時,要寫輸入的資料的形狀(維度、元素量) ```python= model.add(Dense(20, input_shape = (data.shape ), activation = 'relu')) ``` ---- 最後,當我們要確認一個模型的結構,可以使用model.summary() ```python= from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense model = keras.Sequential() model.add(Dense(20, input_shape = (4, ), activation = 'relu')) model.add(Dense(20, ), activation = 'relu') print(model.summary()) ``` output ![](https://i.imgur.com/zxbMimG.png) --- ### activation function ![](https://i.imgur.com/HwbzDFH.png) 神經元的運作原理如下:首先,每個數值從上層神經元輸出時,會乘上上個神經元和目標(現在)神經元間的權重。接著,把上一層每個神經元輸出的值總和。再來,減去(或加)偏差值(bias),偏差值是描述一個神經元被激活的容易度。最後,將得出的數值丟進激活函數處理,模擬人類神經元被激發的狀態。 ---- 較常用的激活函數是Relu(預設) * relu(線性整流函數): 函數會將負數歸零,若大於零則不變。 * sigmoid(S型函數): 使數字縮小於0~1之間,但若觀察上面的函式圖,會發現函數在最右、左端斜率平緩(趨近於0),使模型變得不敏感。常用於分類 * tanh: 和sigmoid一樣,但範圍改至-1~1區間,中間斜率變大,數值收斂更快。但缺點一樣,對極值不敏感。 ---- 文章參考: https://machinelearningmastery.com/choose-an-activation-function-for-deep-learning/ --- ## compile model 在模型學習前,我們還有兩個參數要設定。分別是損失函數(loss)和優化演算法(optimizer)。 深度學習裡的模型學習時,正常狀態下資料會從輸入端進入,並在後面的隱藏層中傳播,直到最後輸出。 (如下圖,點圖有來源) [![](https://i.imgur.com/lIgW84d.png)](https://www.itread01.com/content/1547072313.html) ---- 但是模型中一開始的節點函數、參數都是隨機的,和答案有很大的差距。這裡就要提到深度學習的核心: **誤差反向傳播** **誤差反向傳播**的意思是,將輸出答案和資料的標籤(實際數值、正解)的誤差,從輸出層往前推算,調整權重、參數。就像我們寫數學在驗算時,會從後面一個一個看算式,尋找錯誤、可修改的地方。 ---- 推薦影片: 反向傳播原理(英文) https://www.youtube.com/watch?v=Ilg3gGewQ5U 此時,決定誤差的計算方式和如何調整參數,分別由損失函數和優化函數求出。 ---- #### 參數 在神經網路中,參數有節點間的權重,和激活該節點的偏差值(bias)。 [![](https://i.imgur.com/KCHah3E.png)](https://ithelp.ithome.com.tw/articles/10186671) ---- 那所以每個節點運作的原理到底怎麼運作呢? 首先,當數據(學習資料)從輸入端進入時,經過第一層的激活函數(等下會講)做非線性轉換。當第一筆資料要準備從輸入層到隱藏層時,資料的特徵量會乘上節點間的權重,再加總起來。加總後減去偏差值,帶入激活函數。 推薦影片: https://www.youtube.com/watch?v=aircAruvnKk&list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi&index=2 --- ### 損失函數 loss 上面我們講到,深度學習會利用誤差來調整節點參數。而深度學習最終的目的就是將模型的損失函數降到越小越好。所以,對於模型要學什麼資料時用哪個損失函數很重要,因為它會影響模型的參數,或誤導模型,使模型看起來成功,實際使用卻誤差很大。 這裡我們會介紹一些損失函數: ---- * 均方誤差MSE: [![](https://i.imgur.com/wr5HbP0.png)](https://chih-sheng-huang821.medium.com/%E6%A9%9F%E5%99%A8-%E6%B7%B1%E5%BA%A6%E5%AD%B8%E7%BF%92-%E5%9F%BA%E7%A4%8E%E4%BB%8B%E7%B4%B9-%E6%90%8D%E5%A4%B1%E5%87%BD%E6%95%B8-loss-function-2dcac5ebb6cb) yi --> 實際數值, ^yi --> 模型輸出 ---- 均方誤差常使用於線性回歸,它的運算方式為將預測和實際的誤差平方去平均。之所以用平方的原因,是因為不同數據間的誤差可以抵銷,為了避免此狀況,所以用平方或加絕對值來處理 ---- ---- [![](https://i.imgur.com/vh4KxXZ.png)](https://www.google.com/url?sa=i&url=https%3A%2F%2Fcodingnote.cc%2Fzh-tw%2Fp%2F352824%2F&psig=AOvVaw1rWTQjIhBQShMMpvRm5qiV&ust=1645715404574000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCOjvj8yOlvYCFQAAAAAdAAAAABAD) ---- * 平均絕對值誤差MAE: 和上述一樣,但平方改成絕對值 ![](https://i.imgur.com/Fr2ZzvL.png) ---- * Hinge loss(鉸鏈損失): 用於分類的模型,尤其是SVM支援向量機(這邊先不講,不然太多了。簡單來說在線性分類裡,我們藉由SVM讓不同組的數據盡量越遠越好)。 ![](https://i.imgur.com/DSKsLkd.png) 在這裡t = +-1,模型輸出時,若輸出y和正解t相同,那麼誤差就是0(或是同號)。否則,損失函數會隨著分類的誤差愈大,呈現性成長。 ---- ---- 橫軸為輸出,縱軸為loss ![](https://i.imgur.com/qaS9N8G.png) ---- 其他loss func↓ https://keras.io/api/losses/ --- ### 最佳化演算法 Optimizer 說完loss 損失函數,我們來說優化函數。如同上面所講的,深度學習的目的就在於把損失函數降到最小,透過反向傳播調整參數。 那重點是如何降低損失函數呢? 由於loss是一個函數算出來的(幹話),所以我們目的就是找它的最低點。 我們可以把尋找最低點的方法,想成尋找斜率為'0'的地方,且是往下尋找(斜率為負)。就像你想從山上下來,一定會根據你的所在地,一步一步往下,直到走到山谷。此方法稱**梯度下降法** ---- 補充: 由於我們不可能完全知道函數的圖形,所以我們有可能會找到局部最佳解 [![](https://i.imgur.com/HTaT4tP.png)](https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.cnblogs.com%2Fpacino12134%2Fp%2F11110647.html&psig=AOvVaw2_D9bD6LUCdQp4jbvswXnu&ust=1645718427734000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCIjk_uyZlvYCFQAAAAAdAAAAABAD) ---- 目前我們暫時無法解決這問題。但是就算我們只找到局部最佳解,對我們模型的實際準確率影響微乎其微。 ---- 以下是幾個常用的激活函數 * SGD 機率梯度下降: 最單純的梯度下降法,透過每份學習資料的損失函數,往梯度下降的方向更新參數 * Momentum: 和SGD原理一樣,但若梯度方向一致,則會加快下降速度(如同物理中的慣性一樣) ---- * Adagrad: 根據梯度和參數,調整學習速率(每次下降梯度的大小),但後期下降速率慢(甚至提早結束) * RMSprop: Adagard 的改良版,改善adagrad的問題 * adam: 結合Momentum 和 RMSprop。收斂快,為現今最常使用的激活函數 ---- 設定損失函數和激活函數的方法: ```python= model.compile(loss = 'loss func', optimizer = 'optimizer func', metrics = 模型準確率指標(None)) ``` --- ## fit model 最後,我們要把學習資料丟進模型訓練時,使用fit程式來達成。但同時我們還要設定以下參數。 ---- ### batch_size 每次計算梯度所抓的樣本量(學習資料量),若數量太小,會導致模型在梯度下降效率低。若太大,則非常吃硬體資源 ### epochs 當一份完整的學習資料進入模型並輸出後,稱為1次epoch。但是模型只看一次是不夠的,必須透過好幾次的訓練來調整。 ---- ### shuffle 將數據打亂,由於蒐集資料時我們可能找到已排序好的資料。但是排序好的資料反而會影響模型學習的準確率(例如: 訓練分類模型) ### verbose 是否顯示訓練過程 ### validation_split 有多少個學習資料拿來當成驗證資料 ---- ### evaluate 顯示最終模型的準確度所採用的指標 ---- 程式碼 ```python= model.fit(學習資料, 學習標籤、正解, validation_split = '數值', epochs = num, batch_size = num(預設32), verbose = num(預設0), shuffle = bool(預設false)) model.evaluate(測試資料, 測試標籤) ``` --- ## predict 預測數值,執行模型。 ```python= arr = model.predict(輸入資料) ``` --- ## save and load model 匯出 ```python= tf.saved_model.save(model, "保存的目標資料夾名稱") # 記得要import tensorflow ``` 匯入 ```python= model = tf.saved_model.load("保存的目標資料夾名稱") ``` <!-- ## overfit and under fit ### dropout ## imporve accuracy --> --- ## 參考資料 https://flagtech2020.medium.com/%E6%B7%BA%E9%A1%AF%E6%98%93%E6%87%82%E7%9A%84-ai-%E4%BA%BA%E5%B7%A5%E6%99%BA%E6%85%A7%E7%B0%A1%E5%8F%B2-d3fd8801da4f https://aifreeblog.herokuapp.com/posts/54/data_science_203/ https://ithelp.ithome.com.tw/articles/10196257 --- ## 想要學更多? https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi https://ithelp.ithome.com.tw/users/20112540/ironman/2064?page=1 https://classroom.udacity.com/courses/ud187 --- ## 今日程式連結 https://colab.research.google.com/drive/1hRTaT3vCZvTuW1ew5v56uFg1D58jowiy?usp=sharing

    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