如何透過 JupyterHub 使用 Jupyter Notebook
透過本篇教學文章,您將瞭解如何透過 JupyterHub 使用 Jupyter Notebook 以及執行範例程式碼。
步驟一: 安裝 JupyterHub 並開啟 Notebook 伺服器
您可從 QTS App Center 安裝 JupyterHub 。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_01.jpg)
開啟並登入 JupyterHub。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_02.png)
點擊切換開關以切換成「開啟」,即可啟動 Notebook 伺服器。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_03.png)
畫面將顯示以下項目:
執行中: 檢查已啟動的執行個體
上傳: 上傳本機檔案到伺服器
新增: 開啟新的 Notebook、終端機或資料夾
管理員: 切換到管理員頁面(僅適用於管理員帳號)
登出 Jupyter Notebook
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_04.png)
如果 Notebook 正在執行,請點擊[執行中]以檢視下列頁面。 您也可以點擊[關機]將其關閉。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_05.png)
系統管理員可以進入[管理員]頁面並存取使用者的 Notebook。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_06.jpg)
步驟二: 執行範例程式碼
在清單上選擇 "jupyter_example"。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_07.png)
開啟 "example.ipynb"。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_08.png)
Python 範例程式碼隨即在新的 Notebook 上開啟。
此程式可以透過 Keras 訓練卷積神經網路 (Convolutional Neural Network);這是一種高階神經網路 API,可用於 MNIST 資料集中的手寫數字辨識。
如需詳細資訊,請前往:
- Keras: https://keras.io/
- MNIST: http://yann.lecun.com/exdb/mnist/
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_09.png)
已執行且儲存範例程式碼。 您也可以重新執行程式碼。
點擊[執行]以執行特定片段或循序執行。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_10.png)
點擊[單元](Cell)並選擇[全部執行],執行完整程式碼。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_11.png)
匯入 Keras 資源庫
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_12.png)
匯入其他 Python 資源庫
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_13.png)
載入 MNIST 資料集
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_14.png)
隨機挑選和檢查影像-標籤組合
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_15.png)
預先處理訓練集
調整訓練影像的形狀並將影響標準化
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_16.png)
One-hot 編碼訓練標籤
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_17.png)
逐層建立循序模型
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_18.png)
使用 Adam 優化器,並選擇類別交叉熵 (categorical cross entropy) 作為訓練模型的目標函數。 下列程式碼會執行約數秒。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_19.png)
使用測試集評估模型。 雖然訓練集的準確度應高於 99%,此訓練集的準確度可能會些微降低。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_20.png)
最後會顯示測試結果。
![](https://www.qnap.com/images/products/Application/notes/quai_JupyterHub_21.png)
相關教學文件:
留言
張貼留言
發表一下意見,互動一下唄!