2017/10/11

在 Windows 10 上安裝 Keras 的流程

Keras 是一個在 Python 上的深度學習工具,用這個工具可以快速打造出複雜的類神經網路結構 他需要用到 TensorFlow,所以在安裝 Keras 之前要先安裝 TensorFlow 在安裝 TensorFlow 之前要先安裝 Python 2.7 或 3.5。

先裝 Python

我個人是安裝 Python 3.5,安裝流程請參考 https://pygame.hackersir.org/Lessons/01/Python_install.html, 正確安裝後,在 cmd 下輸入指令:

python -V

若顯示 Python 3.5.2 表示正確安裝。

接著裝 TensorFlow

以下介紹cpu版本的安裝,若需要gpu版本的安裝流程請參考https://rreadmorebooks.blogspot.tw/2017/04/win10cudacudnn.html
在 cmd 下輸入指令:

pip3 install --upgrade tensorflow

裝好後,接著輸入 python 進入互動模式:

python

再輸入以下的 python 程式碼(可直接複製貼上四行)

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

若顯示 b'Hello, TensorFlow!' 表示正確安裝,此時可輸入 exit() 離開 python 互動模式。

SciPy

在裝 Keras 之前,可能需要手動裝 SciPy,因為 SciPy 的自動安裝流程在 Windows 上似乎不完整。 先開啟http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy, 然後點選 scipy‑1.0.0rc1‑cp35‑cp35m‑win_amd64.whl 下載檔案。 下載好了之後,在 cmd 切換目錄至下載目錄,然後輸入指令:

pip3 install scipy1.0.0rc1cp35cp35mwin_amd64.whl

最後裝 Keras

直接在 cmd 輸入指令:

pip3 install keras

裝好後,接著輸入 python 進入互動模式:

python

再輸入以下的 python 程式碼

import keras

若顯示 Using TensorFlow backend. 表示正確安裝,此時可輸入 exit() 離開 python 互動模式。

參考連結:

安裝 Python https://pygame.hackersir.org/Lessons/01/Python_install.html

安裝 TensorFlow https://www.tensorflow.org/install/install_windows

安裝 SciPy http://codewenda.com/windows%E4%B8%8A%E4%BD%BF%E7%94%A8pip%E5%AE%89%E8%A3%85scipy%E9%94%99%E8%AF%AF%EF%BC%9Arunning-setup-py-bdist_wheel-for-scipy-error/

安裝 Keras https://keras-cn.readthedocs.io/en/latest/#_2

沒有留言: