徐海蛟教學
Keras是一個極簡和高度模塊化的神經網絡庫,Keras由純Python編寫而成並基Tensorflow或Theano。Keras 爲支持快速實驗而生,能夠把你的idea迅速轉換爲結果,學習門檻較低。
Windows的版本選擇,可採用Windows 7 / 10作爲基礎環境。
python環境建設推薦使用科學計算集成python發行版Anaconda,Anaconda 是Python衆多發行版中非常適用於科學計算的版本,裏面已經集成了很多優秀的科學計算Python庫。下載地址: Anaconda web(自行搜索,不便粘貼網址),可以從官網下載Anaconda,也可以從清華大學鏡像站點下載,例如下載 Anaconda3-4.2.0-Windows-x86_64.exe,雙擊安裝,很快安裝好了Python 3.5.2。
Keras適用的Python版本是:Python 2.7 ~ 3.5 。
不管是cpu版本還是gpu版本都需要安裝GCC編譯環境。在CMD或者Powershell中輸入:
conda install mingw libpython
在我的電腦上右鍵->屬性->高級->環境變量->系統變量中的path,添加MinGW目錄,例如:
...\Anaconda3\MinGW\bin;...\Anaconda3\MinGW\x86_64-w64-mingw32\lib
Keras深度學習框架是基於Theano或Tensorflow框架安裝的,所以首先要準備底層框架的搭建,然而目前Tensorflow 不支持Windows版本,所以選用Theano安裝即可。
這裏,在 Windows 實驗中未安裝 CUDA包和加速庫CuDNN。
添加pip軟件源,在CMD命令行或者Powershell中輸入:
conda config --show
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes
在CMD命令行或者Powershell中輸入:
pip install theano
pip install keras
出現 Successfully installed theano-0.8.2 表示theano 安裝成功,
出現 Successfully installed keras-1.1.1 表示keras 安裝成功。
驗證數據處理包 NumPy
在CMD命令行或者Powershell中輸入:
python
>>>import numpy; numpy.test()
Ran 5759 tests in 64.460s
OK (KNOWNFAIL=8, SKIP=12)
<nose.result.TextTestResult run=5759 errors=0 failures=0>
>>>
驗證數據處理包 SciPy
>>>import scipy; scipy.test()
Ran 23217 tests in 353.916s
OK (KNOWNFAIL=60, SKIP=1834)
<nose.result.TextTestResult run=23217 errors=0 failures=0>
>>>
驗證深度學習庫 Theano
>>>import theano; theano.test()
>>>
驗證 keras
>>>import keras
Using Theano(Tensorflow) backend.
>>>