Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

python - How to change Keras backend (where's the json file)?

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:Python27libsite-packageskeras__init__.py", line 2, in from . import backend File "C:Python27libsite-packageskerasackend__init__.py", line 64, in from .tensorflow_backend import * File "C:Python27libsite-packageskerasackendensorflow_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:Python27libsite-packageskeras__init__.py", line 2, in from . import backend File "C:Python27libsite-packageskerasackend__init__.py", line 64, in from .tensorflow_backend import * File "C:Python27libsite-packageskerasackendensorflow_backend.py", line 1, in import tensorflow as tf ImportError: No module named tensorflow

Can someone please help? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After looking at keras sources (this place):

Start up your python-binary and do the following

import os
print(os.path.expanduser('~'))
# >>> C:\Users\Sascha'  # will look different for different OS
  • This should be the base-directory
  • Keras will build an folder .keras there where keras.json resides (if it was already created). If it's not there, create it there
  • Example: C:\Users\Sascha\.keras\keras.json'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...