![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python入门
Christopher_Liu_lzh
这个作者很懒,什么都没留下…
展开
-
Python正则表达式匹配C语言函数
以下python代码主要用于匹配各种类型的C语言函数,使用的为re.search,意味着包含,如果需要完全匹配请用re.match。# coding=utf-8import re# 匹配函数,包含函数体function_return_type = r''' (\s*) #匹配所有的空白字符 ( (const)?(volatile)?(static)?\s*(inlin原创 2020-07-17 19:19:37 · 1716 阅读 · 0 评论 -
pytorch使用cuda出错RuntimeError: Expected object of backend CUDA but got backend CPU for argument
第一种情况:数据集忘记转成cuda模式提示RuntimeError: Expected object of backend CUDA but got backend CPU for argumentdevice = torch.cuda('cuda:0')net = MLP()net = net.to(device)data = data.to(device) #而不是直接data.to...原创 2020-03-10 20:03:26 · 1888 阅读 · 1 评论 -
PIP安装Python的scipy,scrapy等包出现“failed building wheel for xxx”问题解决办法
点我原创 2020-03-10 19:46:58 · 732 阅读 · 0 评论 -
pytorch中为什么要用 zero_grad() 将梯度清零
# 调用backward()函数之前都要将梯度清零,因为如果梯度不清零, # pytorch中会将上次计算的梯度和本次计算的梯度累加。这样逻辑的好处是, # 当我们的硬件限制不能使用更大的bachsize时,使用多次计算较小的bachsize的梯度平均值来代替,更方便, # 坏处当然是每次都要清零梯度。 # 总结就是进来一个batch...原创 2020-03-08 00:26:54 · 2966 阅读 · 0 评论 -
Pytorch基础(包括logspace的解释)
https://blog.csdn.net/w55100/article/details/88398841原创 2020-02-26 21:50:35 · 610 阅读 · 0 评论 -
pytorch中文文档
https://pytorch-cn.readthedocs.io/zh/latest/package_references/torch/原创 2020-02-26 21:25:42 · 96 阅读 · 0 评论 -
python读取文件的基本操作
读文件按行读取并不想保留换行符with open('./c.txt', encoding='utf-8') as f: c_function_txt = f.read().split('\n')当碰到产生\ufeff的时候,修改一下格式with open('./c.txt', encoding='utf-8-sig') as f: c_function_txt = f.re...原创 2020-02-26 00:13:07 · 127 阅读 · 0 评论 -
使用sklearn进行交叉验证
转https://www.cnblogs.com/jiaxin359/p/8552800.html转载 2019-03-23 15:33:38 · 337 阅读 · 0 评论 -
安装TensorFlow中提示的一系列问题
No module named ‘numpy.core._multiarray_umath’解决办法:升级numpy下面附上相关链接https://blog.csdn.net/weixin_41010198/article/details/86738635转载 2019-03-16 09:17:13 · 108 阅读 · 0 评论 -
SVM机器学习实战鸢尾花数据集的操作
转https://blog.csdn.net/weixin_42983055/article/details/82387729转载 2019-03-19 21:50:46 · 1589 阅读 · 0 评论 -
python中pandas中的pivot库使用
见https://blog.csdn.net/qq_29118049/article/details/78804768转载 2019-02-18 19:38:35 · 266 阅读 · 0 评论 -
Python中pandas中inplace参数的作用
见https://blog.csdn.net/songyunli1111/article/details/82937954转载 2019-02-18 19:37:42 · 732 阅读 · 0 评论 -
Python的读写操作
这是python写的一些情况,主要会出现Unicode的错误是因为反斜杠的原因,下面是在jupyter notebook上运行的代码和pycharm中的截图#文件对象#这里我是在Pycharm中打开的,开始是乱码,后来调节成utf-8之后正常了poem = '我是一首诗'#打开文件以编辑('w'riting),如果没有直接创建该文件,有的话会抹除原有数据,注意反斜杠的方向!!!#f =...原创 2019-01-15 09:29:42 · 175 阅读 · 0 评论