
上QQ阅读APP看书,第一时间看更新
Using the Theano backend with Keras
- Let's modify the default configuration and change TensorFlow to Theano as the backend of Keras. Modify the keras.json file:
vi .keras/keras.json
The default file has the following content:
{ "image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
- The modified file will look like the following file. The "backend" value has been changed to "theano":
{ "image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}
- Run the Python console and import Sequential from keras.model using the Theano backend:
$ python
Python 2.7.14 |Anaconda, Inc.| (default, Oct 16 2017, 17:29:19)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from keras.models import Sequential
Notice how the backend has changed to Theano.
We have installed miniconda, all the dependencies of TensorFlow, and Theano. This was followed by installing TensorFlow and Theano itself. Finally, we installed Keras. We also learned how to change the backend of Keras from TensorFlow to Theano.