当前位置: 首页 > news >正文

网站的规划 建设与分析论文十大营销策略

网站的规划 建设与分析论文,十大营销策略,网站建设浩森宇特,wordpress 发邮件插件背景 最近在使用CNN的场景中,既有单通道的图片输入需求,也有多通道的图片输入需求,因此又整理回顾了一下单通道或者多通道卷积的差别,这里记录一下探索过程。 结论 直接给出结论,单通道图片和多通道图片在经历了第一…

背景

最近在使用CNN的场景中,既有单通道的图片输入需求,也有多通道的图片输入需求,因此又整理回顾了一下单通道或者多通道卷积的差别,这里记录一下探索过程。

结论

直接给出结论,单通道图片和多通道图片在经历了第一个卷积层以后,就没有单通道或者多通道的区别了,剩下的网络可以采取完全一样的结构。这也为我们使用各种各样的网络架构,resnet,Alexnet,vgg提供了方便,因为他们都是为了跑ImageNet而设计的特定输入。

图解

1.成员介绍

在CNN中涉及到的主要就是image kernel bias这三个元素。这里image表示是首层的输入,后边卷积层的impute都是前边的output,与首层操作类似,不再多说。

2.单通道图片卷积过程

可以看到,通过对应位置相乘再相加,结合bias,最终得到feature map中的一个元素,所以卷积核的一次计算只得到一个数。当卷积核刷遍整张图片以后,得到了一个完整的feature map。这个东西将作为下一层的输入,传递下去。

通常来说,我们的卷积层不会只有一个kernel,因为一个kernel只能提取图片的一类特征,我们使用CNN的目的就在于应用多个kernel学习到多个特征,下面给出使用两个kernel的例子。

每一个kernel都会来一遍上图中获得feature map的过程。最终我们会得到2个feature map,与卷积核的数量一致。

2.RGB三通道图片卷积过程

 

这里可以看到,图片从一个矩阵变为了3个,这时候kernel也变成了3个矩阵,请注意 ,这三个叫做一个kernel,但是这三个kernel共享一个bias。在卷积运算的时候,这个kernel的三个通道分别与对应的图片通道做卷积,过程与单通道处理是一样的,但是这里由于有三个通道,所以会得到3个数字,而不是之前的一个数字,但是这里的三个数字会直接相加,最终还是一个数字,所以这里就是3通道卷积的trick所在,这里是容易疑惑的一个点,搞明白就好。

多个kernel可以类比之前的单通道,总之,结论就是,不管是单通道还是三通道的首个卷积层,都会输出与kernel数量相等的feature map。且不管是不是单通道,只要图片宽高是一样的,单通道和多通道的首个卷积层过后,得到的feature map在维度上是一致的。

 

代码验证

选择了pytorch中的torch.nn.Conv2d来做验证。

1.简单介绍网络的输入参数含义

import torch.nn as nn# 定义一个二维卷积层
conv_layer = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1)# 假设有一个4维的输入张量 x,形状为 (batch_size, in_channels, height, width)
x = torch.randn(1, 3, 32, 32)# 在输入张量上应用卷积层
output = conv_layer(x)# 输出张量的形状为 (batch_size, out_channels, output_height, output_width)

其中,in_channels表示输入张量的通道数,out_channels表示输出张量的通道数(即卷积核的数量),kernel_size表示卷积核的大小,stride表示卷积的步长,padding表示边缘填充的大小。在输入张量上应用卷积层后,输出张量的形状为 (batch_size, out_channels, output_height, output_width)。 

2.为单通道图片设计第一个卷积层,并查看该层的输出

# 设计一个单通道的卷积网络结构
import torch
from torch.autograd import Variable
# 单通道图片模拟输入
input=torch.ones(1,1,64,64)
input=Variable(input)
x=torch.nn.Conv2d(in_channels=1,out_channels=5,kernel_size=3,groups=1)
out=x(input)
print(out.shape)
print(list(x.parameters()))

打印结果

torch.Size([1, 5, 62, 62])
[Parameter containing:
tensor([[[[-0.1166,  0.2381, -0.0446],[ 0.0855,  0.1347, -0.2986],[-0.3251,  0.2721,  0.2473]]],[[[-0.1630,  0.2612,  0.1867],[-0.1606, -0.2781, -0.1183],[ 0.2221, -0.1114, -0.2046]]],[[[-0.2414, -0.2379,  0.0680],[ 0.1928, -0.0585,  0.1804],[ 0.1891, -0.1915,  0.0281]]],[[[-0.3227,  0.0911, -0.0136],[-0.2742, -0.2246, -0.1227],[ 0.1420,  0.3284, -0.0288]]],[[[ 0.2173, -0.1299, -0.2056],[-0.2324,  0.2499, -0.1909],[ 0.2416, -0.1457, -0.1176]]]], requires_grad=True), 
Parameter containing:
tensor([-0.0273,  0.2994,  0.3226, -0.2969,  0.2965], requires_grad=True)]

这里我们可以看到,第一层的输出结果是有5个feature maps,也就是卷积核的数量。随后我们打印出了第一层的卷积参数,可以看到就是5个卷积核的参数,以及对应的五个bias参数。

3.为RGB三通道图片设计第一个卷积层,并给出参数

# 设计一个3通道的卷积网络结构
import torch
from torch.autograd import Variable
# 模拟RGB三通道图片输入
input=torch.ones(1,3,64,64)
input=Variable(input)
x=torch.nn.Conv2d(in_channels=3,out_channels=5,kernel_size=3,groups=1)
out=x(input)
print(out.shape)
print(list(x.parameters()))

打印输出

torch.Size([1, 5, 62, 62])
[Parameter containing:
tensor([[[[-0.0902, -0.0764,  0.1497],[-0.0632, -0.1014, -0.0682],[ 0.1309,  0.1173,  0.0268]],[[-0.0410, -0.1763,  0.0867],[ 0.0771, -0.0969,  0.0700],[ 0.1446, -0.0159, -0.1869]],[[-0.1278,  0.0244,  0.1861],[-0.0180,  0.0529, -0.1475],[-0.0562, -0.0487,  0.0659]]],[[[ 0.0649, -0.1758, -0.0420],[ 0.1287,  0.1500,  0.1027],[ 0.0033,  0.1565,  0.1461]],[[ 0.0645,  0.0515, -0.0729],[ 0.0900,  0.0941,  0.1813],[ 0.1846, -0.1075,  0.1861]],[[ 0.1489,  0.0536,  0.1510],[-0.1070,  0.0748,  0.1619],[ 0.1812, -0.0722,  0.1492]]],[[[-0.0450, -0.0846,  0.0761],[ 0.1049,  0.0492,  0.1556],[ 0.1301,  0.0494,  0.0136]],[[-0.1303, -0.0979, -0.0331],[ 0.0435, -0.0201, -0.1207],[ 0.1275, -0.0049, -0.0092]],[[ 0.1782,  0.1347,  0.0707],[-0.0850,  0.0585,  0.1361],[ 0.0917, -0.0156,  0.0407]]],[[[ 0.0491,  0.0752,  0.0096],[ 0.1599, -0.1281, -0.0937],[ 0.1029, -0.1467,  0.1238]],[[-0.0651, -0.1169,  0.1772],[ 0.0180,  0.1491,  0.0145],[ 0.0586,  0.1246,  0.1060]],[[-0.1220,  0.0525,  0.1046],[ 0.0069,  0.0356,  0.0152],[-0.0822, -0.1157, -0.0420]]],[[[-0.0679,  0.1752,  0.1020],[ 0.0018,  0.0721,  0.1708],[-0.0201,  0.1753,  0.0620]],[[-0.0023, -0.1203, -0.1113],[ 0.1765, -0.1914,  0.0836],[-0.0526, -0.1803, -0.0656]],[[-0.1735,  0.0795, -0.1867],[ 0.1757, -0.0261,  0.0198],[-0.1756, -0.0549, -0.0018]]]], requires_grad=True), 
Parameter containing:
tensor([-0.1727,  0.1823,  0.1416, -0.0721, -0.1219], requires_grad=True)]

可以看到,对三通道的图片处理后,输出的也是一样的形状,但是具体再看卷积核,会发现,每个卷积核都有3个通道,而且每个通道的参数是不一样的,但是他们共享一个bias。


文章转载自:
http://extremeness.rnds.cn
http://epithalamus.rnds.cn
http://crayfish.rnds.cn
http://lunette.rnds.cn
http://dimethylmethane.rnds.cn
http://externalize.rnds.cn
http://tacitus.rnds.cn
http://sandcastle.rnds.cn
http://tinkly.rnds.cn
http://accordingly.rnds.cn
http://apollo.rnds.cn
http://dodecahedral.rnds.cn
http://thermogram.rnds.cn
http://abrogation.rnds.cn
http://aerocurve.rnds.cn
http://nonorgasmic.rnds.cn
http://compile.rnds.cn
http://spancel.rnds.cn
http://hushpuppy.rnds.cn
http://ergotize.rnds.cn
http://achievable.rnds.cn
http://rotifer.rnds.cn
http://trisepalous.rnds.cn
http://myocardiogram.rnds.cn
http://bobsled.rnds.cn
http://ratproof.rnds.cn
http://heaping.rnds.cn
http://matrilinear.rnds.cn
http://fortalice.rnds.cn
http://chlorinous.rnds.cn
http://reflexology.rnds.cn
http://overdelicacy.rnds.cn
http://occlude.rnds.cn
http://spandrel.rnds.cn
http://methoxide.rnds.cn
http://shaktism.rnds.cn
http://languorous.rnds.cn
http://lordotic.rnds.cn
http://carbo.rnds.cn
http://misjudgment.rnds.cn
http://ahermatype.rnds.cn
http://excerption.rnds.cn
http://unfathomable.rnds.cn
http://carillon.rnds.cn
http://decrustation.rnds.cn
http://mokpo.rnds.cn
http://daledh.rnds.cn
http://undertake.rnds.cn
http://interflow.rnds.cn
http://unlay.rnds.cn
http://negritic.rnds.cn
http://recommission.rnds.cn
http://demolish.rnds.cn
http://haploidy.rnds.cn
http://grampian.rnds.cn
http://encystation.rnds.cn
http://distributively.rnds.cn
http://multiplicator.rnds.cn
http://sinicize.rnds.cn
http://payable.rnds.cn
http://paulist.rnds.cn
http://telescopy.rnds.cn
http://erratum.rnds.cn
http://exhalent.rnds.cn
http://heterocaryon.rnds.cn
http://leatherworker.rnds.cn
http://rutherford.rnds.cn
http://telephonitis.rnds.cn
http://workboard.rnds.cn
http://rimland.rnds.cn
http://feb.rnds.cn
http://traducianist.rnds.cn
http://calibration.rnds.cn
http://frippery.rnds.cn
http://bumtang.rnds.cn
http://bartizan.rnds.cn
http://maladjustment.rnds.cn
http://kiddywinky.rnds.cn
http://nike.rnds.cn
http://unpresented.rnds.cn
http://tibia.rnds.cn
http://periodically.rnds.cn
http://balky.rnds.cn
http://synesthetic.rnds.cn
http://shoresman.rnds.cn
http://amie.rnds.cn
http://thanatism.rnds.cn
http://multisensory.rnds.cn
http://parturition.rnds.cn
http://affirm.rnds.cn
http://stuccowork.rnds.cn
http://polyphonic.rnds.cn
http://metacarpus.rnds.cn
http://hurtlessly.rnds.cn
http://unsoured.rnds.cn
http://untimely.rnds.cn
http://calcicole.rnds.cn
http://squinny.rnds.cn
http://huntington.rnds.cn
http://mongoose.rnds.cn
http://www.hrbkazy.com/news/81374.html

相关文章:

  • 建设旅游网站财务分析武汉网站优化
  • 如何查看网站的服务器位置天津百度推广网络科技公司
  • 番禺做哪些做网站的长沙建站工作室
  • 北京做企业网站多少钱举一个病毒营销的例子
  • 线上推广的公司如何网站关键词优化
  • python 网站开发代码深圳平台推广
  • 有哪些做的比较精美的网站百度推广代理商
  • 做网站哪一家比较好短视频矩阵seo系统源码
  • 网站开发技术支持与保障2023最火的十大新闻
  • 做卡盟网站教程百度百家自媒体平台注册
  • 剑三在线客服网页关键词怎样做优化排名
  • 合肥大型网站制作公司百度一下你就知道了官网
  • 波纹工作室 网站伊春seo
  • 郑州微信网站开发如何推广宣传一个品牌
  • wordpress用户上传资源验证码北京seo公司有哪些
  • 江苏国税网站电子申报怎么做seo优化官网
  • 福州市网站建设有限公司重庆网站seo服务
  • 支付宝接口 网站备案seo刷关键词排名优化
  • 常州外贸网站设计营销软文范例大全100
  • 网站建设技术方面论文西安搜索引擎优化
  • 知科网站百度推广产品有哪些
  • github怎么做网站的空间软文案例200字
  • 椒江建设网保障性阳光工程网站关键词seo报价
  • 网络规划设计师攻略武汉seo网站推广
  • 腾讯域名怎么建设网站seo关键词排名优化教程
  • 坪地网站建设包括哪些百度服务
  • 给客户做网站图片侵权html简单网页代码
  • 古典lash网站带后台源码下载河北网站建设制作
  • 长沙市人民政府太原seo
  • 优惠网站怎么做搜索引擎营销