Ce qui fonctionne en python 2.7 - changeant dynamiquement backend Keras
# When I executed the suggestion -- the output I got..
BaseExceptionTraceback (most recent call last)
<ipython-input-7-c4352a2d60e6> in <module>()
3 import keras; import keras.backend
4 if keras.backend.backend() != 'theano':
----> 5 raise BaseException("This script uses other backend")
6 else:
7 keras.backend.set_image_dim_ordering('th')
BaseException: This script uses other backend
- Je ne sais pas comment cela aiderait si nous ne sommes pas en mesure de changer dynamiquement le back-end.
- Au lieu de cela ce qui m'a aidé a été la suivante: How to switch Backend with Keras (from TensionFlow to Theano)
code dans ipython
from keras import backend; print(backend._BACKEND)
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
print ("Change Keras Backend to Theano")
set_keras_backend("theano")
from keras import backend; print(backend._BACKEND)
Sortie en ipython
tensorflow
Change Keras Backend to Theano
theano
Voir [ce] (http: //www.nodalpoint.com/switch-keras-backend/). –
Merci @ ParagS.Chandakkar. Cependant, cela ne fonctionne pas pour moi. Quand je fais 'keras.backend.backend()', il dit toujours 'tensorflow'. Peut-être que je pourrais résoudre ce problème en désinstallant tensorflow? – user3768495
avez-vous essayé KERAS_BACKEND = cahier theano jupyter --no-browser --ip xxx.xxx.xxx.xxx? et ensuite keras.backend.set_image_dim_ordering ('tf') – maz