实用技巧
*小呆
程序...跳了舞
展开
-
python加速记录
python 多进程/线程加速原创 2022-08-18 15:46:44 · 355 阅读 · 0 评论 -
[Linux/pytorch] 内存机制的记录
pytorch 深度学习环境下接触到的几个内存概念。原创 2022-06-22 09:01:32 · 417 阅读 · 0 评论 -
git 管理代码
管理代码步骤图片来源:慕课网Workspace:工作区Index / Stage:暂存区Repository:仓库区(或本地仓库)Remote:远程仓库代码流程cd existing_folder# git 初始化git init# 链接远程的gitlab地址git remote add origin http://gitlabxxxxxxxx.gitgit add -allgit commit# 由于远程库是空的,我们第一次推送master分支时,加上了 –u参数,Git不但原创 2022-06-16 23:04:00 · 313 阅读 · 0 评论 -
linux STAT状态记录
linux原创 2022-06-06 19:16:37 · 484 阅读 · 0 评论 -
matplotlib 二元变量分析
from matplotlib import pyplot as pltimport numpy as npfrom mpl_toolkits.mplot3d import Axes3Dfrom scipy.special import softmaxfig = plt.figure()ax = Axes3D(fig)X = np.arange(0.1, 1, 0.05)Y = np.arange(0.1, 1, 0.05)X, Y = np.meshgrid(X, Y)# Z = X.原创 2022-04-16 21:24:28 · 1685 阅读 · 0 评论 -
Pytorch 随机种子的设置
之前设置过随机种子,但是网络依旧具有随机性。今天刚好看到了mmdetection的实现,才发现之前的code不是所有的随机种子都被固定下来。def set_random_seed(seed, deterministic=False): """Set random seed. Args: seed (int): Seed to be used. deterministic (bool): Whether to set the deterministic .原创 2022-03-06 16:15:30 · 1523 阅读 · 0 评论 -
python process 多进程
查看计算机最大进程数(不支持win)ulimit -uprocess 多进程for 循环用多进程优化,我的电脑测试快了7-8倍,并行数目很大时候会报错,因为计算机无法支持那么多进程。这里我用了一下 i%32==0,先暂时同步一下进程。注意,这部分程序必须写到 __name__ == "__main__" 里面。target后面跟的是函数名称args就是函数的参数列表from multiprocessing import Processif __name__ == "__main__":原创 2022-01-14 17:18:41 · 474 阅读 · 0 评论 -
python 生成目录结构 & 绝对路径导入问题
生成目录结构树状目录结构生成WorkingDirection/├────point2mask/│ └────main-v1.py├────statistics_point/│ ├────__init__.py│ ├────do_statistics.py更改下面代码路径就行了import refrom pathlib import Pathfrom pathlib import WindowsPathfrom typing import Optional, Li原创 2022-01-13 20:27:40 · 337 阅读 · 0 评论 -
更改linux默认缓存:PermissionError: [Errno 13] Permission denied: ‘/.cache‘
export XDG_CACHE_HOME=/path$XDG_CACHE_HOME原创 2021-10-18 21:16:33 · 771 阅读 · 0 评论 -
defaultdict: 强大的dict 子类
整理于 官方网站初始化from collections import defaultdictkey 和 valuekey 是不可变类型value 可以是可变类型,比如 list, set, 当然也可以是不可变类型 int, str举个栗子s = [('yellow', 1), ('blue', 4), ('yellow', 3), ('blue', 2), ('red', 1)]dic = defaultdict(list)for k, v in s: dic[k].ap.原创 2021-08-15 16:12:15 · 124 阅读 · 0 评论 -
csdn 打印pdf
f12 的 控制台输入(function(){ 'use strict'; var articleBox = $("div.article_content"); articleBox.removeAttr("style"); $("#btn-readmore").parent().remove(); $("#side").remove(); $("#comment_title, #comment_list, #comment_bar, #comment_fo原创 2021-07-13 15:13:49 · 209 阅读 · 1 评论 -
pytorch 分布式
返回当前进程组的排名torch.distributed.get_rank() # 返回当前进程组的排名原创 2021-07-12 11:17:47 · 1070 阅读 · 0 评论 -
vs code 调试
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [原创 2021-06-25 20:04:29 · 388 阅读 · 0 评论 -
Python list[:] 的那些小细节
C++ 函数调用变量时候会显式声明究竟是不是引用。而python默认就是引用关系。也就是说函数中更改同名变量(前提是函数中没有define)那么外部的变量就可能会改变。一个小实验展示如下:# 原始地址In [153]: id(nums)Out[153]: 1817895976264# 取切片,已经不是原来的地址了In [154]: id(nums[:])Out[154]: 1817895952584# 再取一个,另开辟一个新的地址In [155]: id(nums[1:])Out.原创 2021-04-24 22:42:37 · 189 阅读 · 0 评论 -
python 刷题实用技巧
binbin函数可以返回一个数字的二进制字符串,如下,其中0b表示二进制。In [4]: bin(3^6)Out[4]: '0b101'count返回具有指定值的元素个数。In [4]: bin(3^6)Out[4]: '0b101'In [5]: bin(3^6).count("1")Out[5]: 2原创 2021-01-31 10:30:44 · 533 阅读 · 0 评论 -
nohup 使用记录
nohup原创 2021-01-12 21:25:34 · 201 阅读 · 0 评论 -
checkpoint_00001.pth.tar 变为 checkpoint_000001.pth.tar
我有五位数的数字和六位数数字的文件我想把五位数数字文件变为六位数。而六位数不变学了一下正则表达式。。。很拙略,但是解决了问题rename -n 's/t_/t_0/' *_[0-9][0-9][0-9][0-9][0-9].pth.tarrename后接一个正则表达式,是perl语法规则的,‘s/’ 是正则匹配的开始的意思,然后第一个/和第二个/之间的部分是被匹配内容,第二个/和第三个/之间是要替换成的内容。-n 先显示效果,不执行命令reference:https://www.cnbl原创 2021-01-09 20:50:56 · 611 阅读 · 0 评论 -
Process finished with exit code 137 调试错误
docker中运行报了一堆子很奇怪的info。最后来一句Process finished with exit code 137这个大概率是内存问题,被系统kill了,所以你没有ctrl c,系统强制ctrl c了。原创 2020-12-10 15:50:02 · 8155 阅读 · 2 评论 -
[win10] Pycharm 记录远程调试逻辑
备忘录,整理逻辑关系步骤1. 打开configuration2. 配置 configuration这个root path是远程绝对路径3. 配置mapping4. 配置系统的编辑器这个路径 使用 which python 找。6. 映射主目录原创 2020-06-04 15:36:57 · 272 阅读 · 0 评论 -
超实用!windows+ipad 文献管理技巧
目录1.下载mendeley2. 修改文件命名方式3. 坚果云等后续衔接1.下载mendeley这个官网下2. 修改文件命名方式参考博客我们可以点击 Tools → File Organizer 进入文件整理设置菜单勾选「Organize my files」并设置新增文献被归档至的文件夹勾选「Sort files into subfolders」来设置按作者/发布期刊/年份/标题自动分类的子文件夹勾选「Rename document files」来设置被分类后文件夹中 PDF 文件批量重新原创 2020-10-26 23:49:20 · 1976 阅读 · 1 评论