TFLearn可以定義為TensorFlow框架中使用的模組化和透明的深度學習方面。TFLearn的主要動機是為TensorFlow提供更高階別的API,以促進和展示新的實驗。
考慮TFLearn的以下重要功能 -
執行以下命令安裝TFLearn -
pip 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])