自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Golden-sun的博客

小小搬运工

  • 博客(132)
  • 资源 (2)
  • 收藏
  • 关注

原创 window设置快捷键左右方向键

autohotkey-windows快捷键设置神器使用方法地址

2021-09-27 09:59:44 919

原创 windows, 放方向键设置为vim格式,autohotkey-windows

安装 Autohotkeyhttps://www.autohotkey.com/download/设置快捷键随便找个目录,鼠标右键新建一个autohotkey的脚本。映射一个键——上左下右经常打字的人都知道,我们编辑文本时要上下左右移动光标,难免要将手移到方向键再移回来打字。对我这样的懒癌后期患者,这简直不能忍。所以我们通过autohotkey将上下左右键映射成其他键。下面是代码:!k:: ;; !->alt键 k->字母键kSend {Up} ;;输入 上 键re

2021-07-05 10:46:18 632

转载 torch.cuda.is_available(),torch.cuda.device_count(),torch.cuda.get_device_name(0)

torch.cuda.is_available()cuda是否可用;torch.cuda.device_count()返回gpu数量;torch.cuda.get_device_name(0)返回gpu名字,设备索引默认从0开始;torch.cuda.current_device()返回当前设备索引;

2021-05-11 19:54:02 3764

原创 DataParallel 和 DistributedDataParallel 的区别和使用方法

1.DataParallelDataParallel更易于使用(只需简单包装单GPU模型)。然而,由于它使用一个进程来计算模型权重,然后在每个批处理期间将分发到每个GPU,因此通信很快成为一个瓶颈,GPU利用率通常很低。nn.DataParallel要求所有的GPU都在同一个节点上(不支持分布式),而且不能使用Apex进行混合精度训练。https://zhuanlan.zhihu.com/p/1136940381.DistributedDataParallel支持模型并行,而DataParallel

2021-04-12 12:07:36 8382 2

原创 Pytorch:数据并行和模型并行,解决训练过程中内存分配不均衡的问题

文章目录数据并行单机多卡训练,即并行训练。并行训练又分为数据并行 (Data Parallelism) 和模型并行两种。数据并行指的是,多张 GPU 使用相同的模型副本,但是使用不同的数据批进行训练。而模型并行指的是,多张GPU 分别训练模型的不同部分,使用同一批数据。数据并行torch.nn.DataParallel(module, device_ids=None, output_device=None, dim=0)【参数】module : 要进行并行的 module。这里隐含了一点 ,即

2021-03-17 19:37:44 1702 1

原创 Shell 在训练模型的时候自动保存训练文件和模型到指定文件夹

在进行深度学习训练的过程中,往往会跑很多实验,这就导致有的实验设置会忘记或者记混淆,我们最好把train test model 的代码都copy一遍到指定文件夹中,这样后面检查也方便。用shell指令保存文件#!/bin/shGRUB_CMDLINE_LINUX="iommu=soft"export CUDA_VISIBLE_DEVICES=1,2,3,4save_dir=./saved_distill_128_fea_ctxif [ ! -d $save_dir ];then #判断文

2021-03-16 18:32:31 477

原创 常用的loss函数,以及在训练中的使用

文章目录KL 散度L2 loss做标准化处理CElossKL 散度import torhch.nn as nnd_loss = nn.KLDivLoss(reduction=reduction_kd)(F.log_softmax(y / T, dim=1), F.softmax(teacher_scores / T, dim=1)) * T * T蒸馏loss T 为L2 lossimport torch.nn.f

2021-03-16 18:28:59 892

原创 RNN,LSTM,GRU的理解

RNNx 为当前状态下数据的输入, h 表示接收到的上一个节点的输入。y为当前节点状态下的输出,而h′h^\primeh′为传递到下一个节点的输出.LSTM#定义网络lstm = nn.LSTM(input_size=20,hidden_size=50,num_layers=2)#输入变量input_data = Variable(torch.randn(100,32,20))#初始隐状态h_0 = Variable(torch.randn(2,32,50))#输出记忆细胞

2021-03-10 18:27:42 155

原创 各种损失损失函数的使用场景和使用方法:KL散度

KL 散度的使用场景KL散度( Kullback–Leibler divergence),又称相对熵,是描述两个概率分布 P 和 Q 差异的一种方法torch.nn.functional.kl_div(input, target, size_average=None, reduce=None, reduction='mean')torch.nn.KLDivLoss(input, target, size_average=None, reduce=None, reduction='mean')第一

2021-03-09 16:38:08 3999 1

原创 torch.backends.cudnn.benchmark 加速训练

设置 torch.backends.cudnn.benchmark=True 将会让程序在开始时花费一点额外时间,为整个网络的每个卷积层搜索最适合它的卷积实现算法,进而实现网络的加速。适用场景是网络结构固定(不是动态变化的),网络的输入形状(包括 batch size,图片大小,输入的通道)是不变的,其实也就是一般情况下都比较适用。反之,如果卷积层的设置一直变化,将会导致程序不停地做优化,反而会耗费更多的时间。添加的位置:在模型的开始之前import torch.backends.cudnn as c

2021-03-03 15:53:01 799 3

原创 cudnn.deterministic = True 固定随机种子

随机数种子seed确定时,模型的训练结果将始终保持一致。随机数种子seed确定时使用相同的网络结构,跑出来的效果完全不同,用的学习率,迭代次数,batch size 都是一样。torch.backends.cudnn.deterministic是啥?顾名思义,将这个 flag 置为True的话,每次返回的卷积算法将是确定的,即默认算法。如果配合上设置 Torch 的随机种子为固定值的话,应该可以保证每次运行网络的时候相同输入的输出是固定的,代码大致这样4种随机种子import torch.backe

2021-03-03 15:49:37 3527 4

原创 Pytorch 各种模块:降低学习率,

1.训练过程中降低学习率if (self.e+1) > (self.num_epochs - self.num_epochs_decay): g_lr -= (self.g_lr / float(self.num_epochs_decay)) d_lr -= (self.d_lr / float(self.num_epochs_decay)) self.update_lr(g_lr, d_lr)

2021-03-02 16:57:20 163

原创 图片拼接的几种方法

1. torch tensor 格式from torchvision.utils import save_image img_train_list = torch.cat([image_s,image_r,im_G[0],fake_A,mask_s[:, :, 0],mask_r[:, :, 0]]) result_path = self.save_path_dir+'/image' if not os.path.exi

2021-03-02 16:46:07 956 1

原创 pytorch:固定部分层参数,固定单个模型

文章目录固定部分层参数固定指定层的参数不同层设置不同的学习率固定部分层参数class RESNET_attention(nn.Module): def __init__(self, model, pretrained): super(RESNET_attetnion, self).__init__() self.resnet = model(pretrained) # 这个model被固定 for p in self.parameters():

2021-03-02 16:45:17 1386 1

原创 Python循环创建变量名

使用命名空间localslocals 中是当前程序段中的全部变量名是一个字典的形式所以我们新增的话,直接和字典那样就行了names = locals() #获取当前程序段中的全体局部变量名 for i in np.arange(0,10): names[f'name_{i}']=i...

2021-03-01 20:46:39 5744 2

原创 python,pytorch:读取,保存,显示图片

文章目录一,Pytorch1. 直接保存Tensor2.Tensor 转CV2 保存二、python1. opencv2.matplotlib:3. PIL一,Pytorch1. 直接保存Tensor#!/usr/bin/env python# _*_ coding:utf-8 _*_import torchfrom torchvision import utils as vutils def save_image_tensor(input_tensor: torch.Tensor, f

2021-02-25 08:48:29 4798 2

原创 在服务器上远程使用tensorboard查看训练loss和准确率

本人使用的是vscode 很简单from torch.utils.tensorboard import SummaryWriterwriter = SummaryWriter('./logs')writer.add_scalar('train_loss',loss.val(),iteration) # 名字,数据,迭代次数训练的过程中会产生一个./logs的文件夹,里面存放的是保存的训练loss数据,然后在命令行运行tensorboard --logdir './logs'...

2021-02-24 23:42:06 1290

原创 Tensorflow代码转pytorch代码 函数的转换

tensoflow函数和pytorch函数之间的转换tensorflowpytrochtf.reshape(input, shape)input.view()tf.expand_dims(input, dim)input.unsqueeze(dim) / input.view()tf.squeeze(input, dim)torch.squeeze(dim)/ input.view()tf.gather(input1, input2)input1[input2

2021-02-24 18:08:49 2535

原创 FTP命令:下载,上传FTP服务器中的文件

步骤 1: 建立 FTP 连接想要连接 FTP 服务器,在命令上中先输入ftp然后空格跟上 FTP 服务器的域名 'domain.com' 或者 IP 地址例如: 1.ftp domain.com 2.ftp 192.168.0.1 3.ftp user@ftpdomain.com注意: 本例中使用匿名服务器。替换下面例子中 IP 或域名为你的服务器地址。步骤 2: 使用用户名密码登录绝大多数的 FTP 服务器是使用密码保护的,因此这些 FTP 服务器会询问'us

2021-02-05 11:49:35 1467

原创 argparse:shell向Python中传参数

一般是python train.py --bath_size 5利用argparse解析参数import argparseparser = argparse.ArgumentParser()parser.add_argument('integer', type=int, help='display an integer')args = parser.parse_args()参数类型可选参数import argparseparser = argparse.ArgumentParser.

2021-02-01 17:26:06 696

原创 Latex: 表格中 自动换行居中

1、在导言区添加宏包:\usepackage{makecell}2、环境:tabular命令:\makecell[居中情况]{第1行内容 \\ 第2行内容 \\ 第3行内容 ...}\makecell [c]{ResNet101\\ (11.7M)}参数说明:[c]是水平居中,[l]水平左居中,[r]水平右居中;[c]水平 + 垂直居中,[l]垂直居中 + 水平左居中,*[r]垂直居中 + 水平右居中。...

2021-01-05 10:17:26 4824

原创 LaTeX:equation, aligned 书写公式换行,顶部对齐

使用aligined 函数,其中aligned就是用来公式对齐的,在中间公式中,\ 表示换行, & 表示对齐。在公式中等号之前加&,等号介绍要换行的地方加\就可以了。\begin{equation}\begin{aligned}L_{task} = &\lambda_1 L_{per}(G_s(x),G_t(x)) +\lambda_1 L_{CE}(y,\delta(z_s))\\ & + \lambda_1L_{Focal}(y,y_{out})\end{al

2020-12-31 09:12:55 26754

原创 面试题目:欠拟合、过拟合及如何防止过拟合

对于深度学习或机器学习模型而言,我们不仅要求它对训练数据集有很好的拟合(训练误差),同时也希望它可以对未知数据集(测试集)有很好的拟合结果(泛化能力),所产生的测试误差被称为泛化误差。度量泛化能力的好坏,最直观的表现就是模型的过拟合(overfitting)和欠拟合(underfitting)。过拟合和欠拟合是用于描述模型在训练过程中的两种状态。一般来说,训练过程会是如下所示的一个曲线图一、什么是欠拟合?欠拟合是指模型不能在训练集上获得足够低的误差。换句换说,就是模型复杂度低,模型在训练集上就表现很差.

2020-12-23 19:26:31 3207

原创 linux 安装python3.8的几种方法

1.命令行搞定git clone https://github.com/waketzheng/carstinocd carstinopython3 upgrade_py.py2.离线安装自己在官网下载安装包https://www.python.org/ftp/python/3.8.0/解压: tar -zvf Python-3.8.0.tgz安装cd Python-3.8.0./configure --prefix=/usr/local/python3make &a

2020-12-14 19:26:00 5069 1

原创 挂载硬盘问题:mount: wrong fs type, bad option, bad superblock on /dev/sdb,

mount: wrong fs type, bad option, bad superblock on /dev/sdb,missing codepage or helper program, or other error解决方案:# create mount dirsudo mkdir /hdd6T# new file systemsudo mkfs.ext4 /dev/sdc# mount drivesudo mount /dev/sdc /hdd6T/# change owner

2020-12-14 15:20:15 12270 4

原创 Python List:合并多个list,listd的合并

第一种方法a = [1,3,3]b = [2,3,3]a =a +bprint(a)[1,3,3,2,3,3]第二种方法a = [1,3,3]b = [2,3,3]a.extend(b)print(a)[1,3,3,2,3,3]

2020-11-24 10:51:40 319

原创 Pytorch RNN 循环网络中 RuntimeError: Trying to backward through the graph a second time

model = RNN()hn = torch.zeros(1,seq_len,hidden_num)epochs = 250clip_value = 100loss = nn.CrossEntropyLoss()optimizer = torch.optim.Adam(model.parameters(),lr=0.001)for epoch in range(epochs): accu,num = 0.0,0 for x,y in data_collect(corpus_i

2020-11-22 15:08:41 682 1

原创 Pytorch:保存图片

1. 直接保存Tensor#!/usr/bin/env python# _*_ coding:utf-8 _*_import torchfrom torchvision import utils as vutils def save_image_tensor(input_tensor: torch.Tensor, filename): """ 将tensor保存为图片 :param input_tensor: 要保存的tensor :param filenam

2020-11-22 13:04:31 1352

原创 pytorch: 在训练中保存模型,加载模型

保存模型torch.save(model, 'model.pkl')model = torch.load('model.pkl')仅保存和加载模型参数(推荐使用)torch.save(model_object.state_dict(), 'params.pkl')model_object.load_state_dict(torch.load('params.pkl'))

2020-11-19 19:16:16 364

原创 测试项目:车牌检测,行人检测,红绿灯检测,人流检测,目标识别

本项目为2020年中国软件杯A组第一批赛题"基于计算机视觉的交通场景智能应用".项目用python实现,主要使用YOLO模型实现道路目标如人、车、交通灯等物体的识别,使用开源的"中文车牌识别HyperLPR"项目实现车牌识别功能.github地址:https://github.com/Kevinnan-teen/Intelligent-Traffic-Based-On-CV安装过程中的报错信息安装PyQt5的时候报错:AttributeError: module ‘sipbuild.api’ has

2020-11-09 22:55:29 1772 2

原创 3090显卡 torch.cuda.is_available()返回false的解决办法

问题1.执行Nvidia-smi 命令没有报错,能够显示驱动信息;2.执行 torch.backends.cudnn.enabled is TRUE3.torch.cuda.is_available()一直返回False解决把torch,torchvision等相关安装包全部删除,安装适合版本的torch。30系列显卡是新一代架构,新驱动不支持cuda9以及cuda10,所以必须安装cuda11、而pytorch现在稳定版为1.6,最高仅支持到cud10.2。所以唯一的办法就是使用上处于beta

2020-11-06 11:53:37 1054

原创 ubunt16.04 安装3090显卡驱动 cuda cudnn pytorch

安装驱动需要的安装包参考https://blog.csdn.net/weixin_43402775/article/details/107610267

2020-11-06 10:15:27 3282

原创 Linux 修改用户名的主目录 家目录

首先root 登陆sudo -i输入密码然后vim /etc/passwd 找到用户名然后修改后面的路径即可

2020-11-05 10:42:19 1730

原创 pytorh .to(device) 和.cuda()的区别

原理可以指定cpu 或者GPUdevice = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")model.to(device)#如果是多GPUif torch.cuda.device_count() > 1: model = nn.DataParallel(model,device_ids=[0,1,2])model.to(device)只能指定GPU#指定某个GPUos.environ['CUDA_

2020-10-22 15:52:13 24060

原创 Latex 生成的PDF增加行号 左右两边

增加行号\usepackage[switch]{lineno}\linenumbers\begin{document}\end{document}

2020-10-18 21:53:16 3826 1

原创 矩阵相加

tensor 类型a = torch.randn(1,3,3)b = torch.randn(1,3,3)c = a + b numpy.array 类型a = np.array([2,2])b = np.array([2,2])print(type(a))print(a+b)[4,4]

2020-10-14 10:11:31 979

原创 .size .shape .size() type的运用

.sizendarray.size 数组元素的总个数,相当于 .shape 中 n*m 的值a = np.array([2,2])print(a.size)2.shapndarray.shape 数组的维度,对于矩阵,n 行 m 列a = np.array([2,2])print(a.shape)(1,2)torch.tensor 数组的维度x = torch.randn(1,64,64,64)print(x.shape)torch.Size([1, 64, 64, 6

2020-10-14 10:03:53 293

转载 计算图片相似度的方法

文章目录1.余弦相似度计算2.哈希算法计算图片的相似度3.直方图计算图片的相似度4.SSIM(结构相似度度量)计算图片的相似度5.基于互信息(Mutual Information)计算图片的相似度1.余弦相似度计算把图片表示成一个向量,通过计算向量之间的余弦距离来表征两张图片的相似度。from PIL import Imagefrom numpy import average, dot, linalg# 对图片进行统一化处理def get_thum(image, size=(64, 64), g

2020-10-14 09:13:30 4766 2

原创 Linux 杀死进程

kill -9 进程名杀死进程

2020-10-13 10:38:22 894

原创 模型压缩 相关文章解读

模型压缩相关文章Learning both Weights and Connections for Efficient Neural Networks (NIPS2015)Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding(ICLR2016)Learning both Weights and Connections for Efficient Neu

2020-10-12 21:18:37 85

Images_ori_(total 10000).zip

photos spanning from 2003 to late 2007. Ages range from 16 to 77 with a median age of 33. The average number of images per individual is 4 and the average time between photos is 164 days, with the minimum being 1 day and the maximum 1681 days. The standard deviation of days between images is 180.

2019-09-15

北邮2016年《计算机科学基础综合》考研真题

北邮计算机学硕考研题目 很方便

2018-10-20

空空如也

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

TA关注的人

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