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

前端 未结 8 1378
南旧
南旧 2020-12-07 16:23

I tried to switch Backend with Keras (from TensorFlow to Theano) but did not manage. I followed the temps described here but it doesn\'t work. I created a keras.json in the

相关标签:
8条回答
  • 2020-12-07 17:20

    In windows, you need to find .keras folder in your C drive. Most probably, it will be somewhere in C:/users/username/. There you will find .keras folder, it contains a json file, keras.json, open it. You will see:

    {
    “backend”: “tensorflow”,
    “floatx”: “float32”,
    “epsilon”: 1e-07
    }
    

    more or less. replace 'tensorflow' with 'theano'. and save the file.

    0 讨论(0)
  • 2020-12-07 17:22

    In case you want to change the config permanently, the json is available here: ~/.keras/keras.json and you can change the backend.

    To do this dynamically in python 2.7 you can run:

    from keras import backend as K
    import os
    
    def set_keras_backend(backend):
    
        if K.backend() != backend:
            os.environ['KERAS_BACKEND'] = backend
            reload(K)
            assert K.backend() == backend
    
    set_keras_backend("theano")
    
    0 讨论(0)
提交回复
热议问题