1.TypeError: unsupported operand type(s) for -: 'list' and 'set'
解决办法:list与dict不能做减法运算,必须同类型,可以改为
dict1 = dict op set(list)
2.UnicodeDecodeError: 'gbk' codec can't decode byte 0xe9 in position 7581: illegal multibyte sequence
打开文件的时候要注意编码问题
几种常见的编码方式
gbk
gb2312
gb18030
utf-8
utf-16
utf-32
ISO-8859-1
f = open(item,"r",encoding='ISO-8859-1')
3.
# p中元素的个数与a中元素个数不相同
# a and p must have same size
>>> np.random.choice([1, 3, 6, 2], 3, p = [0.1])
Traceback (most recent call last):
File "", line 1, in
File "mtrand.pyx", line 1137, in mtrand.RandomState.choice
ValueError: a and p must have same size
# p中的元素之和不为1的时候
>>> np.random.choice([1, 3, 6, 2], 3, p = [0.1, 0.2, 0.5, 0.4])
Traceback (most recent call last):
File "", line 1, in
File "mtrand.pyx", line 1141, in mtrand.RandomState.choice
ValueError: probabilities do not sum to 1
# p值设置正确
>>> np.random.choice([1, 3, 6, 2], 3, p = [0.1, 0.2, 0.4, 0.3])
array([1, 2, 2])
4.tf.matmul报错Shape must be rank 2 but is rank 1
进行matmul操作时两个矩阵的维度出错,导致无法进行操作
5.