首页 > 编程知识 正文

卷积的理解,vhdl std_logic_vector相加

时间:2023-05-03 20:22:42 阅读:128302 作者:244

CNN中的卷积运算是为了特征提取。

卷积操作:

importtorchimporttorchvisionimporttorch.nn.functionalasffromtorchimportnfromtorch.nnimportconv2dfrom torch.utils.datils mmarywriter#输入数据input=torch.tensor ([ 1,2,0,3,1 ],[ 0,1,2,3 ],1 ) )卷积核kernel=torch.tensor () 0] )大小转换input=torch.reshape ) input 3)3*3print(input.shape ) print (kernel.shape ) #卷积操作stride是output 16,16 ],# [ 13,9,3 ] (output2=f.conv 2d (input,kernel,stride=2) print (output2) #tensor ) ) ) kernel,stride=1,padding=1) print ) ) ) output3) )用0填充6 )、# [ 7,18,16,16,8 ]、# [ 11,13,]

图片展示卷积操作流程:

原型: conv2d(in_channels,out_channels,kernel_size,stride=1,padding=0,dilation=1,groups=1,bias=)

参数:

in_channels :输入的通道数

out_channels :要输出的通道数

kernel_size :卷积核的大小

#使用conv 2d dataset=torch vision.datasets.cifa r10 (root='./dataset ',train=False, transform=torch vision.trannsion download=true (数据加载器=数据加载器(数据集,batch_size=64 ) classnnmodule ) self(_init_ () # kernel_size:卷积核大小self.con v1=conv 2d (in _ channels=3,out_channels=6, kernels x ) :x=self.conV1(x ) # 对x执行卷积操作的return xnnModule=NnModule ) ) writer=summarywriter(logs ' ) step=0fordataindater targets=data output=nnn imgs ) imgs是网络的输入print ) imgs.shape ) torch.size ([ 64,3,32,32 ] ) print ) outpput 30 )- [xxx,3,30,30

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。