如何使用 Keras 重建模型並檢查其準確性?
Keras 在希臘語中意為“角”。Keras 是作為 ONEIROS 專案(開放式神經電子智慧機器人作業系統)研究的一部分而開發的。Keras 是一個用 Python 編寫的深度學習 API。它是一個高階 API,具有高效的介面,有助於解決機器學習問題。
Tensorflow 是 Google 提供的機器學習框架。它是一個開源框架,與 Python 結合使用以實現演算法、深度學習應用程式等等。它用於研究和生產目的。
Keras 執行在 Tensorflow 框架之上。它旨在幫助快速進行實驗。它提供了開發和封裝機器學習解決方案所需的必要抽象和構建塊。它具有高度可擴充套件性,並具有跨平臺能力。這意味著 Keras 可以執行在 TPU 或 GPU 叢集上。Keras 模型也可以匯出到 Web 瀏覽器或行動電話上執行。
Keras 已經存在於 Tensorflow 包中。可以使用以下程式碼行訪問它。
import tensorflow from tensorflow import keras
我們正在使用 Google Colaboratory 來執行以下程式碼。Google Colab 或 Colaboratory 幫助在瀏覽器上執行 Python 程式碼,無需任何配置,並可免費訪問 GPU(圖形處理單元)。Colaboratory 基於 Jupyter Notebook 構建。以下是程式碼:
print("Check the accuracy and loss associated with the model")
loss, acc = new_model.evaluate(test_images, test_labels, verbose=2)
print('Restored model, accuracy: {:5.3f}%'.format(100 * acc))程式碼來源 &minus https://www.tensorflow.org/tutorials/keras/save_and_load
輸出
Check the accuracy and loss associated with the model 32/32 - 0s - loss: 0.4021 - sparse_categorical_accuracy : 0.8720 Restored model, accuracy:87.200%
解釋
這個新模型使用“evaluate”方法進行評估。
確定其在訓練過程中的準確性和損失。
這些值顯示在控制檯上。
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP