1. 程式人生 > >深度學習框架keras安裝(後端基於Tensorflow/theano)

深度學習框架keras安裝(後端基於Tensorflow/theano)

1、安裝python3、tensorflow、numpy、scipy

安裝python3及開發工具

sudo apt-get install python3
sudo apt-get install python-setuptools

安裝pip

sudo apt-get install python3-pip

安裝tensorflow/numpy/scipy

pip3 install numpy
pip3 install scipy
pip3 install tensorflow

2、安裝keras

pip3 install keras

3、安裝成功之後的效果

ubuntu:~$ python3
Python 3.5
.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170118] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import keras Using TensorFlow backend. >>> exit()

修改keras配置檔案,可以更改keras後端依賴的框架:
vim ~/.keras/keras.json

{
    "image_data_format": "channels_last"
, "epsilon": 1e-07, "backend": "tensorflow", "floatx": "float32" }

把tensorflow改為theano,
同時把channels_last改為channels_first,
即可切換後端框架,如下:

{
    "image_data_format": "channels_first",
    "epsilon": 1e-07,
    "backend": "theano",
    "floatx": "float32"
}