AttributeError:’module’ object has no attribute ‘ifelse’錯誤資訊的解決方法
在執行訓練卷積神經網路CNN模型進行分類的Python程式碼過程中,出現如下錯誤資訊:
AttributeError:’module’object has no attribute ‘ifelse’
問題分析:
根據錯誤資訊提示,錯誤是在theano_backend.py這個檔案中發生,可見應該是keras的backend(後端) theano出現了問題,進一步查詢發現是kera的版本和theano版本不匹配所致,即所使用的theano版本太新,而keras尚不支援該版本中theano的ifelse介面。
解決方法一(此種方法未經實測)
降級所使用的theano版本,重新安裝0.9版本的theano
解決方法二
修改theano_backend.py這個檔案。
1) 首先切換到theano_backend.py檔案所在目錄:
cd /usr/local/lib/python2.7/dist-packages/keras/backend
2) 然後執行:sudo gedit theano_backend.py &
3) 在檔案頭新增:from theano import ifelse
4) 將第1482行程式碼:
修改為:
儲存後,再次執行Python程式碼,不再報錯,問題成功解決。
相關推薦
AttributeError:’module’ object has no attribute ‘ifelse’錯誤資訊的解決方法
在執行訓練卷積神經網路CNN模型進行分類的Python程式碼過程中,出現如下錯誤資訊: AttributeError:’module’object has no attribute ‘ifelse’
Python指令碼報錯:AttributeError:'model' object has no attribute 'XXX'解決方法
錯誤舉例: 錯位原因定位: 檢視import庫的原始檔,發現原始檔存在且沒有錯誤,同時存在原始檔的.pyc檔案 解決方法: 1、命名py指令碼時,不要與python預留字,模組名等相同 例如:模組是ssl,請不要命名ssl.py檔案,因為程式碼執行時會對應生成.pyc檔案。
unittest中報錯:AttributeError: 'TestLogin' object has no attribute 'driver'解決方法
object login 技術分享 17. ive drive attr info unit 源代碼如下: 更改後: 執行成功。unittest中報錯:AttributeError: 'TestLogin' object has no attribut
pytorch低版本載入高版本pytorch訓練得到的模型,出現‘module’ object has no attribute ‘_rebuild_tensor_v2’錯誤
情景 使用pytorch0.3來載入Mobilenetv1的模型(用更高版本的pytorch訓練得到的),出現“AttributeError: ‘module’ object has no attrib
Deepin下Python2.7安裝Django出現'module' object has no attribute 'lru_cache'錯誤
錯誤資訊如下圖 這裡是解決方案 是Python與Django版本不匹配的問題。 使用pip命令“sudo pip install Django”下載的是Django2
RandomizedSearchCV和GridSearchCV,在呼叫fit方法的時候產生'list' object has no attribute 'values'錯誤之處理方法
【pyhon 版本 3.5.0 skit-learn版本<0.18.1>】 昨天發現的問題,RandomizedSearchCV怎麼都調不通: # Split the dataset in two equal parts X_train, X_test, y_t
Python問題 : AttributeError: 'module' object has no attribute 'SSL_ST_INIT' 解決辦法
pip安裝paramiko包的時候未報錯,但執行pip list | grep paramiko時候報錯如下: $ pip list | grep paramiko Traceback (most recent call last): File "/usr/local/bin/pip
pycharm 安裝第三方庫報錯:AttributeError: 'module' object has no attribute 'main'
pip升級到 10.0.1 之後 老版的pycharm 使用pip安裝第三方庫的時候會報錯,報錯如上圖所示: 其主要原因是 新版的 pip 更改了 部分api 將其中 pip.main() 改為 pip_main(), 舊版的pycharm中 在packagi
import json後,報錯:AttributeError: 'module' object has no attribute 'dumps,原因分析及解決方法
編寫python程式碼,import json後,報錯:AttributeError: 'module' object has no attribute 'dumps',如下圖所示: 報錯資訊為:模組沒有方法dumps 單步除錯: 單步除錯,發現報錯相同。 檢視json
針對AttributeError: ‘module’ object has no attribute’xxx’的錯誤歸類
找不到 with 類型 error: 開頭 -a 發現 使用 def 目前遇見的有三種類型: 拼寫錯誤,模塊一定要拼寫錯誤,這個也是最容易犯的,發現找不到模塊的時候,最好先檢查一遍自己引入的模塊拼寫尤其是那些名字非常長的比如HTTPPasswordMgrWithDefau
Python錯誤:AttributeError: 'Worksheet' object has no attribute 'get_highest_row' 解決辦法
https://blog.csdn.net/gaifuxi9518/article/details/80570746 今天開始學習《python程式設計快速上手》中的第12章:處理Excel電子表格。但是遇到了點小問題。 當我按照書中的方法獲取最大行和最大
AttributeError: '_csv.reader' object has no attribute 'next' 我在使用pyhon3.4執行以下程式碼時報錯:AttributeError:
我在使用pyhon3.4執行以下程式碼時報錯:AttributeError: '_csv.reader' object has no attribute 'next' 1 2 3 4 5 6 7 8
AttributeError:object has no attribute 報錯及解決
報錯情況:在前端測試中,介面傳送一個 PUT 請求,介面發生上面的報錯,請求無法響應,伺服器狀態碼是500。 錯誤分析:語義上是“物件沒有一個XXX屬性”。 查閱大部分資料,大部分說 Python 的問題。這個專案前端使用 React, 後端使用 Python 的 djongo
python AttributeError: 'module' object has no attribute 'setdefaultencoding'
window下使用python,AttributeError: 'module' object has no attribute 'setdefaultencoding'問題的解決方法 參閱了http://www.jb51.net/article/54159.htm後進行整
AttributeError: 'module' object has no attribute 'post'問題
在學習python網頁爬蟲時,測試requests的post方法進行表單提交時,命名.py檔案為requests.py 程式碼如下: import requests params={'firstname':'xing','lastname':'ming'
【pycharm】pycharm上安裝tensorflow,報錯:AttributeError: module 'pip' has no attribute 'main' 解決方法
pycharm上安裝tensorflow,報錯:AttributeError: module 'pip' has no attribute 'main' 解決方法 解決方法: 在pycharm的安裝目錄下,找到helpers/packaging_tool.py檔案,
Python指令碼報錯AttributeError: ‘module’ object has no attribute’xxx’解決方法
最近在編寫Python指令碼過程中遇到一個問題比較奇怪:Python指令碼完全正常沒問題,但執行總報錯"AttributeError: 'module' object has no attribute 'xxx'"。這其實是.pyc檔案存在問題。 問題定位:
AttributeError: 'module' object has no attribute 'urlopen'
編譯環境:python 3.1.2 測試程式: # coding = utf-8 import urllib def getHtml(url): page = urllib.
[python錯誤]builtins.AttributeError: 'module' object has no attribute 'request'
在python3.4.3版本下,使用wingIDE寫爬蟲的時候, 發生了builtins.AttributeError: 'module' object has no attribute 'request'的錯誤。 錯誤來源是程式碼中的 <span style="fo
報錯 AttributeError: 'module' object has no attribute 'bool_'
在使用import numpy時突然出現如下報錯: 出現AttributeError: ‘module’ object has no attribute ‘bool_’報錯. 解決辦法: **因為昨晚安裝caffe,但make報錯就沒有繼續,電腦裡已安