Backend change

3,113 views
Skip to first unread message

Aria Khademi

unread,
Jun 15, 2016, 6:46:42 PM6/15/16
to Keras-users
I'm new to Keras. I'd like to change the backend from the default theano to tensorflow, but I can't find the keras.json file anywhere! I created it in the same folder as my python code, but it didn't change the backend. What should I do?

Matias Valdenegro

unread,
Jun 15, 2016, 7:05:15 PM6/15/16
to keras...@googlegroups.com
keras.json lives inside ~/.keras as described in http://keras.io/backend/

Aria Khademi

unread,
Jun 15, 2016, 7:09:27 PM6/15/16
to Keras-users
I know, but I don't find " .keras" folder. Is it automatically created in the same folder I am running the code? I can't find it there although I have run and compiled a Keras code.

Matias Valdenegro

unread,
Jun 15, 2016, 7:16:58 PM6/15/16
to keras...@googlegroups.com
No, .keras is not the same as ~/.keras, the ~ means your $HOME folder, so
.keras is inside your home folder, not where you are running your code.

Alternatively you could just set the KERAS_BACKEND environment variable to
tensorflow and then run the python code.

Aria Khademi

unread,
Jun 16, 2016, 1:56:17 PM6/16/16
to Keras-users
I did that too. But it does not work. The KERAS_BACKENED variable gets run, it shows that the backend is changed, but then when I run the "python -c "from keras import backend; print backend._BACKEND"", it shows that the backend is theano. Thanks for answering my question, but I guess I just can't switch!

p.nec...@gmail.com

unread,
Jun 17, 2016, 8:58:49 AM6/17/16
to Keras-users
you can also just switch barbarically with os.environ['KERAS_BACKEND']='tensorflow' in your script before importing keras

aruns...@gmail.com

unread,
Oct 13, 2016, 6:27:44 AM10/13/16
to Keras-users, ariak...@gmail.com
Hi Aria.

I too had the same problem in ubuntu. Later I found out that the '.keras'  folder is there in the home folder but is hidden. You can view the hidden files by clicking 'ctrl'+'H' or view-> show hidden files. Now you would be able to see the .keras folder and the configuration file. Change the environmental variable '_BACKEND' and choose the one you needed.
Reply all
Reply to author
Forward
0 new messages