要安裝和配置TFLearn,你需要按照以下步驟進行操作:
pip install tensorflow
pip install tflearn
import tflearn
# 創建一個神經網絡模型
net = tflearn.input_data(shape=[None, 784])
net = tflearn.fully_connected(net, 128, activation='relu')
net = tflearn.fully_connected(net, 64, activation='relu')
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy')
# 定義模型
model = tflearn.DNN(net)
# 訓練模型
model.fit(X_train, Y_train, validation_set=(X_test, Y_test), n_epoch=10, show_metric=True)
# 測試模型
score = model.evaluate(X_test, Y_test)
print('Test accuracy:', score[0])
通過以上步驟,你就可以成功安裝和配置TFLearn,并使用它來構建和訓練神經網絡模型。祝你成功!