Window系統 安裝TFLearn


1. 確保成功安裝了tensorflow

2. 查看當前tensorflow下的庫文件,判斷是否已經安裝了h5py,scipy:conda list

3. 若沒有安裝,安裝h5py,scipy。我的電腦中沒有安裝h5py,安裝:pip install h5py
安裝scipy同理

4. 安裝tflearn
有兩種安裝方式
1)pip install tflearn
2) pip install git+https://github.com/tflearn/tflearn.git (要確保先安裝了Git)
我使用的第一種安裝方法

5. 至此tflearn安裝成功。

6. 從tflearn官網找的一個例子:http://tflearn.org/examples/

from __future__ import absolute_import, division, print_function

import tflearn

# Regression data
X = [3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,7.042,10.791,5.313,7.997,5.654,9.27,3.1]
Y = [1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,2.827,3.465,1.65,2.904,2.42,2.94,1.3]

# Linear Regression graph
input_ = tflearn.input_data(shape=[None])
linear = tflearn.single_unit(input_)
regression = tflearn.regression(linear, optimizer='sgd', loss='mean_square',
                                metric='R2', learning_rate=0.01)
m = tflearn.DNN(regression)
m.fit(X, Y, n_epoch=1000, show_metric=True, snapshot_epoch=False)

print("\nRegression result:")
print("Y = " + str(m.get_weights(linear.W)) +
      "*X + " + str(m.get_weights(linear.b)))

print("\nTest prediction for x = 3.2, 3.3, 3.4:")
print(m.predict([3.2, 3.3, 3.4]))

運行結果部分截圖如下:

 


--------------------------------分割線--------------------------------------------
安裝過程中遇到的錯誤


1. hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience)
原因:沒有安裝h5py,安裝h5py后,問題得以解決

2. curses is not supported on this machine (please install/reinstall curses for an optimal experience)
解決方法:安裝curses
安裝過程:
1)如果沒有安裝wheel,首先通過pip命令安裝wheel:pip install wheel

2)從https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下載curses‑2.2‑cp35‑none‑win_amd64.whl包

3)cd到下載的.whl的目錄(如我的 ~/PythonTool)。直接輸入命令 : pip install curses-2.2-cp36-cp36m-win32.whl

參考:https://github.com/lxzheng/machine_learning/wiki/TensorFlow--%E5%92%8C-TFlearn-Windows%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM