andy6804tw 1010code 10程式中
自動調參神器 Optuna
線上直播乾貨分享
andy6804tw 1010code 10程式中 2
國立臺南大學
資訊工程學系碩士
台灣人工智慧學校
南部分校工程師
簡介:
l 熱衷於技術研究,也有經營 Blog 與 YouTube 頻道分享實作教學
l 研究領域包括機器人智慧型代理人、模糊專家系統與機器學習、
腦機介面與情緒評估、深度學習
l 擅於網頁前後端並整合機器學習
講師簡介
講師
andy6804tw 1010code 10程式中 3
今日學習目標
l Optuna 如何採樣參數?
l 實作 Optuna 搜尋最佳超參數
l 以 XGBoost 迴歸模型於房價預測為例
l Optuna 視覺化分析搜尋結果
目錄
andy6804tw 1010code 10程式中 4
何謂超參數?
以神經網路來解釋:
l 參數 (Parameters)
l 參數是訓練模型時學習出的,譬如如權重w與偏差值b 。
l 超參數 (Hyperparameters)
l 超參數則是則是由人為給定,例如神經網路的層數、損失函數、卷積核的大小、學習率等等。
andy6804tw 1010code 10程式中 5
機器學習模型超參數 (XGBoos t 為例)
l n_estimators: 總共迭代的次數,即決策樹的個數。預設值為100。
l max_depth: 樹的最大深度,預設值為6。
l booster: gbtree 樹模型(預設) / gbliner 線性模型
l learning_rate: 學習速率,預設0.3。
l gamma: 懲罰項係數,指定節點分裂所需的最小損失函數下降值。
andy6804tw 1010code 10程式中 6
整個專案過程中超參數隨處可見
• Augmentation ?
• Image size ?
• Image format ?
• Backbone Architecture:
VGG? ResNet? Xception?
• Kernel size ?
• Number of FPN layers?
• Batch size ?
• Optimizer ?
• Learning rate schedule?
• IOU threshold ?
• Model quantization:
FP16 ? FP32 ?
• Which cuda kernel
parameters?
andy6804tw 1010code 10程式中
而我們要如何決定超參數的數值呢?
7
andy6804tw 1010code 10程式中 8
如何決定超參數的數值?
最常見的方法就是在網路上參考其他人的模型架構,而如果要對超參數做微調時,因為超參數眾多,往
往也是藉由實驗的方式進行設計。
l 經驗法則
l 逐一的試錯 (Trial and Error)
l 運氣與直覺
andy6804tw 1010code 10程式中 9
情境:手動調參
Trial 1
Accuracy: 0.6
試試這些超參數
• learning_rate: 0.1
• max_depth: 3
Trial 2
Accuracy: 0.7
Trial 3
Accuracy: 0.5
試試這些超參數
• learning_rate: 0.3
• max_depth: 6
試試這些超參數
• learning_rate: 0.01
• max_depth: 9