如何使用 Estimators 在 Tensorflow 中分割鳶尾花資料集?
可以透過刪除不相關的特徵來提取鳶尾花資料集的關鍵特徵/列名。這可以使用“pop”方法來完成。
閱讀更多: 什麼是 TensorFlow 以及 Keras 如何與 TensorFlow 協作建立神經網路?
我們將使用 Keras Sequential API,它有助於構建一個順序模型,用於處理簡單的層堆疊,其中每一層只有一個輸入張量和一個輸出張量。
包含至少一層卷積層的神經網路稱為卷積神經網路。我們可以使用卷積神經網路構建學習模型。
TensorFlow Text 包含一系列與文字相關的類和操作,可用於 TensorFlow 2.0。TensorFlow Text 可用於預處理序列建模。
我們正在使用 Google Colaboratory 來執行以下程式碼。Google Colab 或 Colaboratory 幫助在瀏覽器上執行 Python 程式碼,無需任何配置,並可免費訪問 GPU(圖形處理單元)。Colaboratory 是建立在 Jupyter Notebook 之上的。
Estimator 是 TensorFlow 中對完整模型的高階表示。它旨在實現輕鬆擴充套件和非同步訓練。
示例
print("Species feature is deleted")
train_y = train.pop('Species')
test_y = test.pop('Species')
print("After deleting the column, sample data is being displayed")
train.head()程式碼來源 −https://www.tensorflow.org/tutorials/estimator/premade#first_things_first
輸出
Species feature is deleted After deleting the column, sample data is being displayed SepalLength SepalWidth PetalLength PetalWidth 0 6.4 2.8 5.6 2.2 1 5.0 2.3 3.3 1.0 2 4.9 2.5 4.5 1.7 3 4.9 3.1 1.5 0.1 4 5.7 3.8 1.7 0.3
解釋
- “species”特徵被刪除。
- 其餘列與示例資料一起顯示在控制檯上。
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP