自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 TypeError: the JSON object must be str, not 'bytes'

json.loads(lines)报错修改为json.loads(lines.decode())即可一些修改为load什么的方法会带来新的报错…直接添加decode()解决

2019-03-20 14:11:23 5404

转载 Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

如图,加入如下代码即可解决。import osos.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

2019-03-19 15:20:00 227

转载 解决:python将json文件转换为txt,txt汉字正则(如\u5982\u4f55)

在之前代码中加入ensure_ascii=False即可解决即tr_data = json.dumps(tr_data, ensure_ascii=False)亲测有效,主要是因为汉字是ascii 字符码,而不是真正的中文。(json.dumps 序列化时对中文默认使用的ascii编码)所以需要指定ensure_ascii=False...

2019-03-17 18:12:44 4138 1

原创 解决PyCharm:no module named

Files —— settings —— Project interpreter 切换项目接口即可如果还是没有的话可以选择右边加号添加

2019-03-17 16:44:58 1370

原创 升级pip报错:AttributeError: 'NoneType' object has no attribute 'bytes'

python -m pip install --upgrade pip修改为easy_install -U pip即可解决亲测有效

2019-03-17 16:28:01 911

原创 Python报错TypeError: expected string or bytes-like object

出现于正则表达式,主要意思是数据类型不匹配。file = open("./he.txt", 'r')corpus = file.read()word = str(corpus)pattern = re.findall(r'(因为.{,})', word) # 这里re.findall(corpus)会报错,因为数据不是str型print(pattern)修改:转换数据结构,...

2019-03-06 11:07:30 62685 5

原创 python报错:在float转int时,利用map,出现<map object at ......>

python报错:在float转int时,利用map函数,出现<map object at …>问题result.append(sum((data_left-left)**2)+sum((data_right-right)**2)) # 算平方误差Result = (map(int, result))这里result中的值均为float,在用map转为list时,出现了如下图问...

2019-01-04 22:52:25 773

转载 python画图报错:Unknown projection '3d'

python画图报错:Unknown projection ‘3d’加入from mpl_toolkits.mplot3d import Axes3D即可

2019-01-03 21:05:52 11464 5

原创 报错:pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

安装好tesseract后,在cmd可以运行。如下之后在pycharm中运行时,出现报错:pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path解决方法:在pytesseract.py中,将tesseract_cmd = 'tesseract'改...

2018-12-21 14:39:17 6936 1

转载 AdaBoostClassifier参数

Adaboost-参数:base_estimator:基分类器,默认是决策树,在该分类器基础上进行boosting,理论上可以是任意一个分类器,但是如果是其他分类器时需要指明样本权重。n_estimators:基分类器提升(循环)次数,默认是50次,这个值过大,模型容易过拟合;值过小,模型容易欠拟合。learning_rate:学习率,表示梯度收敛速度,默认为1,如果过大,容易错过最优值,...

2018-12-18 23:21:51 5921

原创 python报错ValueError: Found input variables with inconsistent numbers of samples: [x,y]

出现这种错误是因为在训练的过程中,测试图片(train_images)和测试标签(train_labels)的长度必须一致。也就是说你有60000张训练数据,就必须有60000张标签,这样才可以匹配。总的来说,二者长度(个数)必须一样即可。...

2018-12-18 23:14:26 53592 10

原创 python报错:'list' object has no attribute 'shape'

numpy.array可使用 shape。list不能使用shape。可以使用np.array(list A)进行转换。(array转list:array B B.tolist()即可)

2018-12-18 23:03:56 101461 6

转载 python错误:IndentationError:unindent does not match any outer indentation level

我用的是pycharm,对缩进有着非常严格的要求。一般出现这种问题,大家仔细检查自己的缩进就ok了特别是在循环和函数的return

2018-12-18 12:01:14 142

原创 python错误:No module named 'sklearn.cross_validation'

调用from sklearn.cross_validation import train_test_split时,发现错误:No module named 'sklearn.cross_validation’更改为sklearn.model_selection即可from sklearn.model_selection import train_test_split...

2018-12-18 11:58:49 1577 2

原创 python 错误 SyntaxError: invalid character in identifier

即“标识符中的无效字符”。有些编译器会报错,比如pycharm。但是jupyter等等,运行后才会显示如上错误。仔细检查一下代码中有没有中文字符,一般来说是分号(;;)等等,也要注意tab和四个space是不一样的。(虽然看起来一样╯^╰)...

2018-12-18 11:53:12 1670

原创 python问题:UnicodeDecodeError: 'utf-8' codec can't decode byte in position : invalid start byte

完成机器学习作业时,读取西瓜数据集的.csv文件,发现出现以上错误:UnicodeDecodeError: ‘utf-8’ codec can’t decode byte in position : invalid start byte看过很多大佬的解决方案都不能搞定,其实问题就是在存在无法进行转换的二进制数据。追其根源,是因为编码方式。大家只需要修改文件编码方式为UTF-8即可。步骤:右键...

2018-12-15 16:03:56 25185 5

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除