How to switch Backend with Keras (from TensorFlow to Theano)

Create a .keras (note the . in front) folder in you home directory and put the keras.json file there.

For example, /home/DaniPaniz/.keras/keras.json (or ~/.keras/keras.json in short) if you are on a UNIX like system (MacOS X, Linux, *BSD). On Windows you want to create the folder %USERPROFILE%/.keras and put the JSON file there.

Alternatively, you can also set the environment variable KERAS_BACKEND:

KERAS_BACKEND=theano python mymodel.py

Leave a Comment