pytorch
学习
后悔大鲨鱼
这个作者很懒,什么都没留下…
展开
-
pytorch基于cpu下的速度测试及cpu线程设置
libtorch默认是将cpu性能全部耗光,cpu利用率达到95%,需要设置并行计算的线程数,设置函数是torch::set_num_threads(1);python版本的torch.set_num_threads(1)resnet50模型cpu型号:I7 4770 3.6HZ 内存16Gpytorch 单线程cpu速度大概285ms 增加线程速度反而降低 两个线程300ms 4个线程350ms gpu 750ti 85mslibtorch 单线程...转载 2021-09-01 10:31:55 · 2162 阅读 · 1 评论 -
RuntimeError: “slow_conv_transpose2d_out_cpu“ not implemented for ‘Half‘
场景:使用CPU生成解决:原创 2021-08-30 10:17:52 · 5489 阅读 · 1 评论 -
RuntimeError: The size of tensor a (128) must match the size of tensor b (32) at non-singleton dimen
我的问题:网络输入大小是固定的,没有resize输入图像。其他问题:(13条消息) RuntimeError: The size of tensor a (128) must match the size of tensor b (32) at non-singleton dimen_S20144144的博客-CSDN博客原创 2021-07-28 16:18:07 · 3142 阅读 · 3 评论 -
RuntimeError: Attempting to deserialize object on CUDA device 1 but torch.cuda.device_count() is 1.
读参数时,用map_location,gpu 1 -> gpu 0torch.load('modelparameters.pth', map_location={'cuda:1':'cuda:0'})参考:pytorch cpu与gpu load时相互转化 torch.load(map_location=)_bc521bc的博客-CSDN博客原创 2021-07-23 11:09:35 · 438 阅读 · 0 评论 -
.whl文件安装cuda10.0版本的pytorch1.3.0+torchvision0.4.1
$ python3 -m venv env3$ source env3/bin/activate$ cd env3/share/python-wheels在此找到对应的版本:https://download.pytorch.org/whl/cu100/torch_stable.html$ wget https://download.pytorch.org/whl/cu100/torch-1.3.0%2Bcu100-cp36-cp36m-linux_x86_64.whl$ wget https..转载 2021-07-21 18:22:00 · 442 阅读 · 0 评论 -
pytorch----torchsummary报错TypeError: ‘module‘ object is not callable
Usagepip install torchsummary or git clone https://github.com/sksq96/pytorch-summaryfrom torchsummary import summarysummary(your_model, input_size=(channels, H, W))Note that theinput_sizeis required to make a forward pass through the networ...原创 2020-09-10 16:16:29 · 3532 阅读 · 1 评论 -
pytorch----Error:dict object has no attribute eval
问题:原因:没有创建model实例解决方法:转载 2020-09-09 14:44:42 · 10462 阅读 · 0 评论 -
pytorch----扩展/压缩tensor维度
1. 扩展Tensor维度 当输入的数据维度和实验需要维度不一致,输入的可能是2维数据或3维数据,实验需要用到3维或4维数据,则需要扩展这个维度。1.1torch.unsqueeze(self: Tensor, dim: _int) torch.unsqueeze(self: Tensor, dim: _int) 参数说明:self:输入的tensor数据,dim:要对哪个维度扩展就输入那个维度的整数,可以输入0,1,2……1.2Code第一种方式,输入数据后直接加un...转载 2020-09-09 10:57:23 · 1876 阅读 · 0 评论 -
pytorch----Target 2 is out of bounds
问题:多分类网络加了两层全连接后最后输出1类,计算loss时报错Target Nis out of bounds其中的N其实就是处理的数据输入的标签,即第几类,是一个代表类别的整数,最后输出1类与输入的target不符就会报错解决方法:查看网络的最后输出,softmax的输出节点数是否等于所有的标签数。...原创 2020-09-09 10:15:09 · 12951 阅读 · 3 评论 -
pytorch----ImageFolder
torchvision已经预先实现了常用的Dataset,包括前面使用过的CIFAR-10,以及ImageNet、COCO、MNIST、LSUN等数据集,可通过诸如torchvision.datasets.CIFAR10来调用。在这里介绍一个会经常使用到的Dataset——ImageFolder。ImageFolder假设所有的文件按文件夹保存,每个文件夹下存储同一个类别的图片,文件夹名为类名,其构造函数如下:ImageFolder(root, transform=None, target_trans转载 2020-09-03 17:15:42 · 131 阅读 · 0 评论 -
pytorch----数据处理,datasets、DataLoader及其工具的使用
torchvision是PyTorch的一个视觉工具包,提供了很多图像处理的工具。datasets使用ImageFolder工具(默认PIL Image图像),获取定制化的图片并自动生成类别标签。如裁剪、旋转、标准化、归一化等(使用transforms工具)。DataLoader可以把datasets数据集打乱,分成batch,并行加速等。一、datasets获取原图或格式化的图,自动命名标签1.1 获取原图片使用torchvision.datasets中的ImageFolder工具转载 2020-09-01 10:29:47 · 621 阅读 · 0 评论 -
pytorch预训练模型下载URL及加载调用方法
一、预训练模型URL1. Classification 分类AlexNetmodel_urls = { 'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',}VGGmodel_urls = { 'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30ac9.pth', 'vgg13': 'https://d转载 2020-08-21 18:34:14 · 3925 阅读 · 3 评论 -
pytorch加载预训练模型(.pth格式)
pytorch自带模型网址:https://pytorch-cn.readthedocs.io/zh/latest/torchvision/torchvision-models/官方预训练模型调用代码:https://github.com/pytorch/vision/tree/master/torchvision/models官方文档地址 :https://pytorch.org/docs/master/torchvision/models.html1. 按官网加载预训练好的模型:原创 2020-08-21 18:15:28 · 20090 阅读 · 0 评论