![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Conv2d
那里,春暖花开
这个作者很懒,什么都没留下…
展开
-
resnet50特征图分辨率和通道数的变化
resnet50输出4个特征图。4个特征图的分辨率依次为原始图片的1/4, 1/8, 1/16, 1/32,通道数依次为256,512,1024,2048。import torch.nn as nnimport mathimport torch.utils.model_zoo as model_zoo__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152']mod原创 2020-07-12 00:07:15 · 10619 阅读 · 1 评论 -
特征图分辨率的降低,保持,提高
卷积输入输出分辨率大小公式当kernel大小为3,padding为1,stride为1的时候,卷积前后的特征图分辨率大小不变import torchimport torch.nn as nnfrom PIL import Imageimport numpy as npconv = nn.Conv2d(3, 4, kernel_size=3, stride=1, padding=1, bias=False)file = 'lena.png'img = Image.o原创 2020-07-06 22:35:57 · 2406 阅读 · 0 评论 -
pytorch中Conv2d的FLOPs的计算范例
import torchconv = torch.nn.Conv2d(1,8,(2,3))input = torch.rand(1,1,224,224) # batch,channel,width,heightoutput = conv(input)print(output.shape)bn = torch.nn.BatchNorm2d(8)l = [conv,bn]for module in l: class_name = str(module.__class__.__name__原创 2020-06-13 16:14:06 · 1148 阅读 · 1 评论 -
查看Conv2d,BN两类module的参数大小
import torchconv = torch.nn.Conv2d(1,8,(2,3))bn = torch.nn.BatchNorm2d(8)l = [conv,bn]for module in l: print('{}.weight.data.size()'.format(str(module.__class__.__name__)),module.weight.data.size())原创 2020-06-13 13:07:54 · 664 阅读 · 0 评论 -
pytorch计算module的参数量
import torchconv = torch.nn.Conv2d(1,8,(2,3))bn = torch.nn.bBatchNorm2d(8)l = [conv,bn]for module in l: params = 0 for param_ in module.parameters(): print(param_) params += param_.view(-1).size(0) print(module,params)可以看到原创 2020-06-13 12:09:27 · 578 阅读 · 0 评论 -
pytorch获取module的classname
import torchconv = torch.nn.Conv2d(1,8,(2,3))bn = torch.nn.BatchNorm2d(8)l = [conv,bn]for item in l: print(item.__class__.__name__)输出结果:Conv2dBatchNorm2d原创 2020-06-13 11:40:48 · 1469 阅读 · 1 评论 -
测试pytorch的Conv2d的类继承关系
Conv2d是一个torch.nn.Module,但不是torch.nn.ModuleListimport torchconv = torch.nn.Conv2d(1,8,(2,3))if not isinstance(conv,torch.nn.ModuleList): print('not ModuleList')if isinstance(conv,torch.nn.Module): print('is torch.nn.Module')输出结果not ModuleLis原创 2020-06-13 11:20:39 · 348 阅读 · 0 评论