TFLearn 功能包括:
# Classification
tflearn.init_graph(num_cores=8, gpu_memory_fraction=0.5)
net = tflearn.input_data(shape=[None, 784])
net = tflearn.fully_connected(net, 64)
net = tflearn.dropout(net, 0.5)
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy')
model = tflearn.DNN(net)
model.fit(X, Y)
# Sequence Generation
net = tflearn.input_data(shape=[None, 100, 5000])
net = tflearn.lstm(net, 64)
net = tflearn.dropout(net, 0.5)
net = tflearn.fully_connected(net, 5000, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy')
model = tflearn.SequenceGenerator(net, dictionary=idx, seq_maxlen=100)
model.fit(X, Y)
model.generate(50, temperature=1.0)
[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
这里还有更多示例。
TFLearn 基于原始的 tensorflow v1 图形 API。使用 TFLearn 时,请确保以这种方式导入 tensorflow:
import tflearn
import tensorflow.compat.v1 as tf
安装 TensorFlow
TFLearn 需要安装 Tensorflow(版本 2.0+)。
要安装 TensorFlow,只需运行:
pip install tensorflow
或者,在 GPU 支持下:
pip install tensorflow-gpu
有关详细信息,请参阅TensorFlow 安装说明
TFLearn 安装
要安装 TFLearn,最简单的方法是运行
对于最前沿的版本(推荐):
pip install git+https://github.com/tflearn/tflearn.git
对于最新的稳定版本:
pip install tflearn
否则,您也可以通过运行(从源文件夹)从源安装:
python setup.py install
[/hidecontent]