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])