forked from MorvanZhou/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-backend.py
47 lines (33 loc) · 1005 Bytes
/
3-backend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
To know more or get code samples, please visit my website:
https://morvanzhou.github.io/tutorials/
Or search: 莫烦Python
Thank you for supporting!
"""
# please note, all tutorial code are running under python3.5.
# If you use the version like python2.7, please modify the code accordingly
# 3 - backend
"""
Details are showing in the video.
----------------------
Method 1:
If you have run Keras at least once, you will find the Keras configuration file at:
~/.keras/keras.json
If it isn't there, you can create it.
The default configuration file looks like this:
{
"image_dim_ordering": "tf",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}
Simply change the field backend to either "theano" or "tensorflow",
and Keras will use the new configuration next time you run any Keras code.
----------------------------
Method 2:
define this before import keras:
>>> import os
>>> os.environ['KERAS_BACKEND']='theano'
>>> import keras
Using Theano backend.
"""