TFLearn可以定义为TensorFlow框架中使用的模块化和透明的深度学习方面. TFLearn的主要动机是为TensorFlow提供更高级别的API,以促进和展示新的实验.
考虑TFLearn : 的以下重要特征;
TFLearn易于使用和理解.
它包含易于构建的概念高度模块化的网络层,优化器和嵌入其中的各种指标.
它包括TensorFlow工作系统的完全透明性.
它包含强大的辅助函数来训练内置的张量,这些张量接受多个输入,输出和优化器.
它包括简单和美丽的图形可视化.
图形可视化包括权重,渐变和激活的各种细节.
执行以下命令安装TFLearn :
pip install tflearn
e执行上面的代码,将生成以下输出 :
下图显示了TFLearn与Random Forest分类器的实现 :
from __future__ import division, print_function, absolute_import#TFLearn module implementationimport tflearnfrom tflearn.estimators import RandomForestClassifier# Data loading and pre-processing with respect to datasetimport tflearn.datasets.mnist as mnistX, 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])