python
五阿哥爱跳舞
零散知识记录,分享投稿全流程经验(附赠投稿所需各类说明文件,中稿率加倍,包括cover letter模版等)
展开
-
错误修正:RunError: one of the variables needed for gradient computation has been modified
inplace operation 就是直接对tensor的内容进行修改,而没有使用复制的副本 (An in-place operation is an operation that changes directly the content of a given Tensor without making a copy)。原创 2024-03-05 22:06:40 · 358 阅读 · 0 评论 -
python基础
python基础总结原创 2023-09-11 11:04:04 · 134 阅读 · 0 评论 -
*** IndexError: index 1 is out of bounds for dimension 0 with size 1
复现Swin-Unet跑自己的数据的时候,出现的问题,主要原因就是数据是奇数,而batch_size开的偶数,因此[1]这个batch_size的位置有问题了,越界了,应该改成0。原创 2022-11-07 23:14:51 · 8689 阅读 · 12 评论 -
【python基础】List列表中插入多个元素的几种实现方式
【python基础】列表中插入多个元素的几种实现方式。原创 2022-07-28 23:27:50 · 7481 阅读 · 0 评论 -
DGL GPU版本加速训练时遇到的各种错误总结,以及常见错误解决方案
文章目录1.常见问题解决路径1.1官网问题反馈页面1.2github的issue页面2.我遇到的问题2.1 RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat2 in method wrapper_mm)2.2 dgl._ffi.base.DGLError: Ca原创 2022-03-23 22:40:27 · 6340 阅读 · 0 评论 -
python数据处理/pandas教程:数据预处理、数据存储、数据加载等等
python数据处理:数据预处理、数据存储、数据加载等等一、数据加载常用工具包2.1pandas使用二、数据预处理三、数据存储一、数据加载常用工具包pandas:https://pandas.pydata.org/2.1pandas使用参考资料:pandas之数据存储 https://www.cnblogs.com/harden13/p/12987359.html二、数据预处理三、数据存储...原创 2021-07-05 22:27:11 · 569 阅读 · 0 评论 -
Python scipy.csr_matrix() SCR矩阵压缩方法简单理解
CSR方法采取按行压缩的办法, 将原始的矩阵用三个数组进行表示from scipy import sparsedata = np.array([1, 2, 3, 4, 5, 6]) #所有的非零数值indices = np.array([0, 2, 2, 0, 1, 2]) #所有值得列索引indptr = np.array([0, 2, 3, 6]) #每行的的非零数据 data[ indptr[i]:indptr[i+1] ]csrmatrix原创 2021-01-12 16:00:47 · 825 阅读 · 0 评论 -
torch.flatten()
#张量推平比如现在有一个2×3×4的张量Ax = tensor.flatten(A) 默认去掉所有维度,生成一个 24维的张量x = tensor.flatten(A, start_dim=0, end_dim=1) 则生成一个6*4的张量 dim=0对应2 dim=1对应3 dim=2对应4原创 2021-01-02 16:00:37 · 331 阅读 · 0 评论 -
python @property的介绍与使用
文章目录python @property的介绍与使用1.修饰方法,是方法可以像属性一样访问。2.与所定义的属性配合使用,这样可以防止属性被修改。转载:原文链接python @property的介绍与使用python的@property是python的一种装饰器,是用来修饰方法的。作用:我们可以使用@property装饰器来创建只读属性,@property装饰器会将方法转换为相同名称的只读属性,可以与所定义的属性配合使用,这样可以防止属性被修改。使用场景:1.修饰方法,是方法可以像属性一样访问。转载 2021-01-02 14:09:22 · 105 阅读 · 0 评论 -
一文读懂:python中的装饰器@
一文读懂Python装饰器 @很简单,名字叫做装饰器,肯定就是用来装饰东西的啊,用谁来装饰谁呢? 用**@后面的东西来装饰@下一行的东西**;另外我们要知道,python中传递的参数不仅仅可以是变量、类等,方法也可以直接进行传递;举个例子def function(f): f() print('a')@functiondef function2(): print('b')function2()result:ba什么意思呢:首先,你要知道python中函数是可以传递的;其次,原创 2021-01-02 12:53:01 · 133 阅读 · 0 评论