TensorFlow - TFLearn 及其安裝



TFLearn 可以定義為模組化且透明的深度學習方面,用於 TensorFlow 框架。TFLearn 的主要動機是為 TensorFlow 提供一個較高級別的 API,以便促進和展示新的實驗。

考慮 TFLearn 的以下重要特徵 −

  • TFLearn 易於使用和理解。

  • 它包含易於構建高度模組化網路層、最佳化器及其內嵌的各種度量的概念。

  • 它包含與 TensorFlow 工作系統完全的透明性。

  • 它包含強大的幫助函式,用於訓練內建的接受多輸入、輸出和最佳化器的張量。

  • 它包含簡單美觀的圖形視覺化。

  • 圖形視覺化包括權重、梯度和啟用的各種詳細資訊。

透過執行以下命令安裝 TFLearn −

pip install tflearn

執行上述程式碼後,會生成以下輸出 −

Install TFLearn

以下插圖顯示了透過隨機森林分類器實現 TFLearn −

from __future__ import division, print_function, absolute_import

#TFLearn module implementation
import tflearn
from tflearn.estimators import RandomForestClassifier

# Data loading and pre-processing with respect to dataset
import tflearn.datasets.mnist as mnist
X, Y, testX, testY = mnist.load_data(one_hot = False)

m = RandomForestClassifier(n_estimators = 100, max_nodes = 1000)
m.fit(X, Y, batch_size = 10000, display_step = 10)

print("Compute the accuracy on train data:")
print(m.evaluate(X, Y, tflearn.accuracy_op))

print("Compute the accuracy on test set:")
print(m.evaluate(testX, testY, tflearn.accuracy_op))

print("Digits for test images id 0 to 5:")
print(m.predict(testX[:5]))

print("True digits:")
print(testY[:5])
廣告
© . All rights reserved.