2017-02-20 105 views
0

autoencoder_layers.py github code我試圖運行autoencoder_layers.py使用基於GPU keras但我得到這個錯誤

import theano 
from keras import backend as K 
from keras.backend.theano_backend import _on_gpu 
from keras.layers.convolutional import Convolution2D, UpSampling2D 
from keras.layers.core import Dense, Layer 
from theano import tensor as T 
from theano.sandbox.cuda import dnn 

,但我得到這個錯誤:

/home/hoda/anaconda2/bin/python /home/hoda/Downloads/keras-convautoencoder-master/autoencoder_layers.py 
Using gpu device 0: GeForce GTX 970M (CNMeM is disabled, cuDNN not available) 
Using Theano backend. 
Traceback (most recent call last): 
    File "/home/hoda/Downloads/keras-convautoencoder-master/autoencoder_layers.py", line 3, in <module> 
    from keras.backend.theano_backend import _on_gpu 
ImportError: cannot import name _on_gpu 

如何解決呢?

回答

0

註釋行from keras.backend.theano_backend import _on_gpu,並定義爲_on_gpu

def _on_gpu(): 
    return theano.config.device[:3] == 'gpu' 

這將解決您的錯誤。

+0

謝謝!!它修復了它! –

+0

不客氣。你能接受答案嗎? – indraforyou

相關問題