无涯教程-TensorFlow - TFLearn安装

60 阅读1分钟

TFLearn可定义为TensorFlow框架使用模块化且透明的深度学习,TFLearn的主要功能是为TensorFlow提供更高级别的API,以促进和展示新的实验。

通过执行以下命令来安装TFLearn-

pip install tflearn

执行以上代码后,将生成以下输出-

Install TFLearn

下图显示了带有随机森林分类器的TFLearn的实现-

from __future__ import division, print_function, absolute_import

#TFLearn 模块实现 import tflearn from tflearn.estimators import RandomForestClassifier

# 关于数据集的数据加载和预处理 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])

参考链接

www.learnfk.com/tensorflow/…