Keras深度学习框架学习笔记(3) - AttributeError:’module’ object has no attribute ‘ifelse’错误信息的解决方法
2017-10-17 15:40
1291 查看
在运行训练卷积神经网络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’
问题分析:
根据错误信息提示,错误是在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 '_handlerList' 错误解决方法
- 【python学习笔记(2)】脚本报错"AttributeError: 'module' object has no attribute 'xxx'"解决方法
- AttributeError: 'module' object has no attribute 的解决方法
- AttributeError: 'module' object has no attribute 的解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- Scrapy AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1 解决方法
- Ubuntu运行scrapy报“scrapy: 'module' object has no attribute 'OP_SINGLE_ECDH_USE'错误解决方法”
- Python2.7 安装mock出现AttributeError: 'module' object has no attribute的解决方法
- GNU Radio自定义模块在添加到流图后运行报‘module’ object has no attribute错误的解决方法
- AttributeError: 'module' object has no attribute 'Frame' 解决方法
- AttributeError: 'module' object has no attribute 的解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- 解决方法——AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- yum错误'module' object has no attribute 'iterparse'解决方法
- Python基础学习-'module' object has no attribute 'urlopen'解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- AttributeError: 'module' object has no attribute '_base' 可行解决办法
- AttributeError: 'module' object has no attribute 'Frame' 解决方法
- web.py 启动时候出现AttributeError: 'module' object has no attribute 'inet_pton'错误