I have installed Keras, and wanted to switch the backend to Theano. I checked out this post, but still have no idea where to put the created json file. Also, below is the error I got when running import keras
in Python Shell:
Using TensorFlow backend.
Traceback (most recent call last): File "", line 1, in import keras File "C:\Python27\lib\site-packages\keras__init__.py", line 2, in from . import backend File "C:\Python27\lib\site-packages\keras\backend__init__.py", line 64, in from .tensorflow_backend import * File "C:\Python27\lib\site-packages\keras\backend\tensorflow_backend.py", line 1, in import tensorflow as tf ImportError: No module named tensorflow
When running python -c "import keras; print(keras.__version__)"
from Windows command line, I got:
Using TensorFlow backend. Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\keras__init__.py", line 2, in from . import backend File "C:\Python27\lib\site-packages\keras\backend__init__.py", line 64, in from .tensorflow_backend import * File "C:\Python27\lib\site-packages\keras\backend\tensorflow_backend.py", line 1, in import tensorflow as tf ImportError: No module named tensorflow
Can someone please help? Thanks!
"Can’t find your keras.json file? : Windows
On most systems the keras.json file (and associated sub-directories) will not be created until you open up a Python shell and directly import the keras package itself.
If you find that the ~/.keras/keras.json file does not exist on your system, simply open up a shell, (optionally) access your Python virtual environment (if you are using virtual environments), and then import Keras:
"
Referenced from : keras-with-tensorflow/theano-backend
In case of Ubuntu,the following worked for me:
The '.keras' folder is present in your home directory,but is hidden.So,you need to unhide the hidden files in your home directory. You can see the hidden files in Ubuntu by
You can now see the '.keras' folder in your home directory.Inside that folder,you will see the 'keras.json' file which you can modify to switch the keras backend to theano according to the official documentation https://keras.io/backend/
For those with a python shell open:
For Linux systems, the hidden .keras directory will be created in the user’s home directory. To observe whether or not it has been created, run the following command from your home directory (the -a allows you to see hidden files and directories).
If the directory is there, then cd into it and modify the keras.json file. If it’s not there, then create the directory with
Then create the file with
Then edit the file to make the config changes you referenced to change the backend engine to Theano.
This process is covered fully in this video.
You can directly use,
or
After looking at keras sources (this place):
Start up your python-binary and do the following
.keras
there wherekeras.json
resides (if it was already created). If it's not there, create it thereC:\\Users\\Sascha\\.keras\\keras.json'