
python
irober
这个作者很懒,什么都没留下…
展开
-
pytorch安装
pytorch安装原创 2023-06-16 17:01:48 · 641 阅读 · 0 评论 -
“conda update -n base -c defaults conda“无效
conda更新问题原创 2023-06-16 15:20:03 · 2586 阅读 · 3 评论 -
No module named ‘torch_geometric‘解决办法
python torch-geometric的安装转载 2022-07-22 10:11:47 · 1589 阅读 · 0 评论 -
解决方法:AttributeError: module ‘torch.nn.parameter‘ has no attribute ‘UninitializedParameter‘
解决在使用torch-geometric构建图神经网络出现module ‘torch.nn.parameter’ has no attribute 'UninitializedParameter’错误的一种简单办法。原创 2022-07-22 09:58:39 · 2258 阅读 · 1 评论 -
关于Vscode中jupyter出现kernel dead问题
关于Vscode中jupyter出现kernel dead问题针对我遇到的这个问题,我使用的方法。进入Anaconda Prompt,输入jupyter kernelspec list查看安装的内核和位置发现在我安装的虚拟环境tf2.1中并没有ipykernel进入虚拟环境:activate tf2.1输入conda install ipykernel安装ipykernel即可经过上述操作,我的程序可以在VScode中成功运行。...原创 2022-03-21 10:45:07 · 2852 阅读 · 0 评论 -
UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
基于torch1.8.1 训练模型时,出现如下warning,记录解决方法。UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.解决:出现警告的原因,是torch版本的更新导致之前的参数不再使用。然而警告并不影响代码运行,所以可以不管。但是,为了输出不再出现警告,可加入忽视warning的代码:import warningswarnings.filterwarnings原创 2021-12-27 09:25:27 · 3508 阅读 · 0 评论 -
RuntimeError: An attempt has been made to start a new process before the current pro
pytorch 代码调试中出现以下报错。报错:RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child pro原创 2021-12-27 09:16:22 · 2065 阅读 · 1 评论 -
终端进程启动失败: shell 可执行文件“C:\Windows\System32\cmd.exe ”的路径不存在。
运行vscode时遇到cmd无法启动的问题。主要原因,你的程序配置没有设置该文件路径,将该路径添加进来即可。具体操作:查看你打开文件夹下的.vscode文件夹下的settings.json文件,如下图:添加"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",,如下图所示:其中,增加的其他项,是本程序依赖的其他路径。...原创 2021-10-09 21:20:51 · 20461 阅读 · 1 评论 -
Python封装程序 python串口助手
步骤如下:(1)安装pyinstaller,可以直接在cmd命令行中,输入命令“pip install pyinstaller”,安装pyinstaller(2)进入py代码的保存目录,这里py代码放在“I:\EIT\matlab要熟悉的\手势\手势采集上位机”(3)地址栏输入“cmd”得到(4)执行命令:pyinstaller -F pyserial_demo.py ui_demo_1.py(5)执行成功后,会保存在相同目录下的文件“dist”中,可以将exe文件复制出来后,删除其他自动原创 2021-03-16 10:48:44 · 412 阅读 · 1 评论 -
Pytorch矩阵乘法之torch.mul() 、 torch.mm() 及torch.matmul()的区别
torch.mul() 、 torch.mm() 及torch.matmul()的区别一、简介torch.mul(a, b) 是矩阵a和b对应位相乘,a和b的维度必须相等,比如a的维度是(1, 2),b的维度是(1, 2),返回的仍是(1, 2)的矩阵;torch.mm(a, b) 是矩阵a和b矩阵相乘,比如a的维度是(1, 2),b的维度是(2, 3),返回的就是(1, 3)的矩阵。torch.bmm() 强制规定维度和大小相同torch.matmul() 没有强制规定维度和大小,可以用利用广原创 2021-02-05 12:27:46 · 34432 阅读 · 4 评论 -
Python字典切片
Python字典切片python 的 list, string, tuple 都提供了切片操作,用起来非常方便。有时候会需要对字典进行截取,只需要其中一部分数据。然而 python 的 dict 没有提供类似的切片操作,所以就得要自己实现。其实也很简单:先取出所有 keys,再对 keys 切片,然后用得到的键去字典里找值重新创建一个新的字典。示例代码:def dict_slice(adict, start, end): keys = adict.keys() dict_slice =原创 2021-02-04 15:48:07 · 24739 阅读 · 3 评论 -
vscode-git中的U,M和D文件标记含义
vscode-git中的U,M和D文件标记含义M modified你已经在github中添加过该文件,然后你对这个文件进行了修改,就会文件后标记MU untracked你在本地新建了这个文件,还未提交到github上,就会标记UD delete你删除了这个文件,vscode-git会记录下这个状态6,U表示有6个错误且untracked这些标记可以很清晰地帮助你查看工作区每个文件的git状态...转载 2021-02-02 11:07:26 · 3191 阅读 · 3 评论 -
Anaconda复制Conda的虚拟环境
Anaconda复制Conda的虚拟环境一、clone旧环境来创建新环境二、 删除旧环境深度学习过程中,同一个服务器上,多个用户的虚拟环境可以通过clone互相使用,省去重新搭建环境的步骤。conda并没有对环境重命名这一操作,我们可以通过先clone旧的环境,然后删除旧环境(可选)来等效地对旧环境重新命名下面是本机实际操作:一、clone旧环境来创建新环境我们几个用户都使用了安装在user用户下的Anaconda。而且都有sodo权限。conda create -n chf_keras --c原创 2021-01-15 09:36:12 · 3342 阅读 · 1 评论 -
数据科学你可能遇到的有关代码的查询
kaggle_房价预测kaggle竞赛房价预测–排名前4%jupyter notebook目录导航Python可视化 | Seaborn pairplotstats.probplot(QQ图)Python数据可视化-seaborn库之countplot人工智能实战就业(面试)学习路线图imputeitems()python enumerate用法总结...原创 2020-09-28 16:38:53 · 132 阅读 · 0 评论 -
python3循环命名
python3循环命名在python中,对于有规律的变量名,我们可以采取循环命名的方式。譬如,我要生成5个列表,分别命名为list_0-----list_4。1、数字类型循环命名list_test = ['我','要','学','EIT','。']#批量生成列表prepare_list = locals() #locals()以字典类型返回当前位置的全部局部变量for i in range(5): list_ = 'list_' + str(i) prepare_list[li原创 2020-08-28 16:26:28 · 9610 阅读 · 2 评论 -
2020年 python串口收发数据
python串口收发数据一、虚拟串口安装二、利用虚拟串口工具,将com2和com3串口连接起来三、程序示例一、虚拟串口安装链接:https://pan.baidu.com/s/1_0bwdg-XYFNYelWui7WaZA 提取码:prnz安装过程见:虚拟串口安装与破解二、利用虚拟串口工具,将com2和com3串口连接起来如果无法创建端口对,可能原因:这两个端口号至少一个被占用或者软件破解失败。三、程序示例导入相应的依赖包,事先未安装的需要安装。安装办法:pip install pysri原创 2020-07-03 09:31:23 · 2177 阅读 · 4 评论 -
python如何打开一个txt文件
python如何打开一个txt文件一、读文件1、简单的将文件读取到字符串中2、按行读取整个文件3、将文件读入数组中二、写文件1、简单的将字符串写入txt中2、列表写入文件文件的打开的两种方式f = open("data.txt","r") #设置文件对象f.close() #关闭文件#为了方便,避免忘记close掉这个文件对象,可以用下面这种方式替代with open('data.txt',"r") as f: #设置文件对象 str = f.read() #可以是随便对文件转载 2020-07-03 08:57:34 · 9315 阅读 · 4 评论 -
re.findall() in python-----如何取出一组字符串中的数字(整数或小数)
如何取出一组字符串中的数字(整数或小数)import re>>> s = '4 and 10.2356'>>> re.findall(r'\d+(?:\.\d+)?', s)['4', '10.2356']>>> print(int(re.findall(r'\d+(?:\.\d+)?', s)[0]))4>>> print(float(re.findall(r'\d+(?:\.\d+)?', s)[1]))10.235原创 2020-07-02 19:24:35 · 4265 阅读 · 1 评论 -
module ‘serial’ has no attribute ‘Serial’
module ‘serial’ has no attribute ‘Serial’问题代码:import serial # 导入pyserialcom = serial.Serial('com3', 115200) # 实例化串口,com3,波特率115200报错:module ‘serial’ has no attribute ‘Serial’解决办法:1、卸载serial;2、卸载pyserial;3、重新打开你的编辑器。pip uninstall serialpip uninsta原创 2020-07-02 16:56:43 · 25773 阅读 · 4 评论 -
Tkinter pyimage不存在----image “pyimage10“ doesn‘t exist
Tkinter pyimage不存在----image “pyimage10” doesn’t exist运行环境:Spyder(python3.7)或者jupyter notebook运行例程:import tkinter as tkwindow = tk.Tk()window.title('my window')window.geometry('200x200')canvas = tk.Canvas(window, bg='blue', height=100, width=200)i原创 2020-07-02 15:09:39 · 4234 阅读 · 3 评论 -
pip install PIL 报错: Could not find a version that satisfies the requirement PIL
pip install PIL 报错: Could not find a version that satisfies the requirement PILPIL 已经被 Pillow 所替代了,所以使用 pip install PIL 不行,要将其改成 pip install Pillowpip install Pillow -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn.原创 2020-07-02 10:48:42 · 377 阅读 · 0 评论 -
pandas DataFrame数据重命名列名的几种方式
pandas DataFrame数据重命名列名的几种方式前言一 部分列重命名二 全部列重命名三 str 批量修改列名四 读取csv文件重命名后记前言首先,我们创建一个5行4列的DataFrame数据作为示例,进行演示import pandas as pdimport numpy as npdf = pd.DataFrame(data=np.arange(20).reshape(5,4), columns=[‘a’, ‘b’, ‘c’, ‘d’])dfa b c d0 0 .转载 2020-06-30 14:10:47 · 17767 阅读 · 1 评论 -
读取文件夹下指定的文件名
读取文件夹下指定的文件名当文件夹下存在不同名称的文件。譬如hello1.txt,hello2.txt,hello3.txt,如何将其取出呢?import osimport stringinputFilePath= ".\data2" #你存放文件的文件夹pathfile_0 = [] #提取文件名后存放文件名的列表pathfile_1 = []pathfile_2 = []for file in os.listdir(inputFilePath): if os原创 2020-06-29 09:52:54 · 460 阅读 · 0 评论