Tensorflow 简明教程
TensorFlow - TFLearn And Its Installation
TFLearn 可定义为用于 TensorFlow 框架的模块化和透明的深度学习环节。TFLearn 的主要目的为 TensorFlow 提供高级的 API 以实现新实验。
TFLearn can be defined as a modular and transparent deep learning aspect used in TensorFlow framework. The main motive of TFLearn is to provide a higher level API to TensorFlow for facilitating and showing up new experiments.
考虑 TFLearn 的以下重要特质 −
Consider the following important features of TFLearn −
-
TFLearn is easy to use and understand.
-
It includes easy concepts to build highly modular network layers, optimizers and various metrics embedded within them.
-
It includes full transparency with TensorFlow work system.
-
It includes powerful helper functions to train the built in tensors which accept multiple inputs, outputs and optimizers.
-
It includes easy and beautiful graph visualization.
-
The graph visualization includes various details of weights, gradients and activations.
执行以下命令安装 TFLearn −
Install TFLearn by executing the following command −
pip install tflearn
执行以上代码后,将生成以下输出 −
Upon execution of the above code, the following output will be generated −
下图显示了 TFLearn 与 Random Forest 分类程序的实现 −
The following illustration shows the implementation of TFLearn with Random Forest classifier −
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])