概述
(ctrl+F
大法~
错误:
from keras.layers import merge
# 然后调用merge(),报错
TypeError: 'module' object is not callable(不可调用)
原因: Keras在2.1.6版本后去除了merge()
查看Keras版本
:pip show keras
解决方案: 就是将keras
版本回退到2.1.6
或之前的版本
修改版本:pip install keras==2.1.6
(修改到2.1.6)
错误:
`validation_steps=None` is only valid for a generator based on the
`keras.utils.Sequence.Please specify `validation_steps` or
use the `keras.utils.Sequence` class.
原因: 数据量过少,而Batch_Size
大,导致计算的validation_steps
一直为0。
解决方案: 可以缩小Batch_Size
,或者直接指定validation_steps
值,我的缩小Batch_size也没用,检查发现是因为数据划分出错导致测试集为空,更正后就行了。
报错:
TypeError: 'range' object does not support item assignment
原因: range() 返回的是“range object”,而不是实际的list 值。
解决方案:
shuffle_index = range(self.nb_train)
改为:
shuffle_index = list(range(self.nb_train))
错误:
ImportError: cannot import name 'izip'
原因: python3里的zip
就相当于python2 itertools里的izip
解决方案:
# from itertools import izip 注释掉
izip = zip
错误:
zip' object has no attribute 'sort'
原因: zip()
在Python 3中返回迭代器 ; 当从中请求元素时,输入将被压缩。迭代器不可排序
解决方案:
可以使用sorted()
“绘制”元素并从中返回排序列表:
如将:
ziped = zip(y_true[i], y_priord[i])
ziped.sort(key=lambda x: x[1], reverse=True)
更正为:
ziped = sorted( zip(y_true[i], y_priord[i]) , key=lambda x: x[1], reverse=True )
详见StackOverflow回答
错误:
mysql> GRANT ALL PRIVILEGES ON DB.* TO 'scraper1'@'localhost' IDENTIFIED BY 'passwd';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'passwd'' at line 1
原因:
mysql8.0
版本创建用户和授权更严格,要先创建用户设置密码,才能授权。
解决方案:
mysql> status
可以查看当前版本
创建用户scraper1
设置密码passwd
:
create user 'scraper1'@'localhost' identified by 'passwd'
授与其所有权限:
grant all privileges on DB.* to 'scraper1'@'localhost' with grant option;
最后
以上就是缥缈裙子为你收集整理的遇到的各类报错汇总查用的全部内容,希望文章能够帮你解决遇到的各类报错汇总查用所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复