2017-03-08 5 views
2

Keras documentation page의 지침에 따라 keras.json 파일을 변경했습니다. 그러나 Ipython 노트북에서는 Tensorflow를 백엔드로 사용하고 있다고합니다.Ipython 노트북의 Theano로 케라 백엔드 변경

enter image description here

어쩌면 그것은 어떻게 든 Jupyter 설정과 관련이 있습니까? 친절하게 도와주세요. 나는 문제가 어디서 왔는지 파악하는 방법조차 모릅니다. 감사!

+1

페이지의 [이] (HTTP를 : -

대신 어떤 날 다음되었다 도움 : //www.nodalpoint.com/switch-keras-backend/). –

+0

Thanks @ ParagS.Chandakkar. 그러나 그것은 나를 위해 작동하지 않습니다. 'keras.backend.backend()'를 할 때 여전히'tensorflow'라고합니다. 어쩌면 tensorflow를 제거하여 thsis 문제를 해결할 수 있습니까? – user3768495

+0

시도해 보셨습니까? KERAS_BACKEND = theano jupyter notebook --no-browser --ip xxx.xxx.xxx.xxx? 그리고 나서 keras.backend.set_image_dim_ordering ('tf') – maz

답변

2

당신은 노트북의 시작에서 다음을 시도해 볼 수도 있습니다 :

import os 
os.environ["KERAS_BACKEND"] = "theano" 
import keras; import keras.backend 
if keras.backend.backend() != 'theano': 
    raise BaseException("This script uses other backend") 
else: 
    keras.backend.set_image_dim_ordering('th') 
    print("Backend ok") 

기본적으로 환경 KERAS_BACKEND는 Jupyter에 의해 어느 시점에 덮어 씌우 할 수 있도록이 당신이 keras을 가져 오기 전에 뭔가를 할 강제하는 방법 중 하나입니다. 백엔드. 파이썬 2.7에서 작동 무엇

0

- 우리가 동적으로 백엔드를 변경할 수 없습니다 경우이 도움이 될 방법, 확실하지 - 동적으로 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 

변경. How to switch Backend with Keras (from TensionFlow to Theano)

코드 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) 

출력을 iPython에

tensorflow 
Change Keras Backend to Theano 
theano