Pytorch重要函数(nn.Conv2d;nn.ConvTranspose2d)
Posted 小葵花幼儿园园长
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Pytorch重要函数(nn.Conv2d;nn.ConvTranspose2d)相关的知识,希望对你有一定的参考价值。
卷积层
class torch.nn.Conv1d(
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
dilation=1,
groups=1,
bias=True
)
in_channels
:(int) —输入信号的通道out_channels
:(int)—卷积产生的通道kerner_size
:(int or tuple(元组))—卷积核的尺寸stride
:(int or tuple, optional)—卷积步长padding
:(int or tuple, optional)—输入的每一条边补充0的层数dilation
:(int or tuple, optional)—卷积核元素之间的间距groupd
:(int,optional)—从输入通道到输出通道的阻塞连接数bias
:(bool,optional)—如果bias=True,添加偏置
一维卷积:
- 输入:(N,C_in, L)
- 输出: (N, C_out,L_out)
o u t ( N i , C o u t j ) = b i a s ( C o u t j ) + ∑ C i n − 1 k = 0 w e i g h t ( C o u t j , k ) ⨂ i n p u t ( N i , k ) out(N_i, C_{out_j})=bias(C {out_j})+\\sum^{C{in}-1}{k=0}weight(C{out_j},k)\\bigotimes input(N_i,k) out(Ni,Coutj)=bias(Coutj)+∑Cin−1k=0weight(Coutj,k)⨂input(Ni,k)
二维卷积:
- 输入:(N,C_in,H_in,W_in)
- 输出: (N,C_out,H_out,W_out)
H o u t = f l o o r ( ( H i n + 2 p a d d i n g [ 0 ] − d i l a t i o n [ 0 ] ( k e r n e r l s i z e [ 0 ] − 1 ) − 1 ) / s t r i d e [ 0 ] + 1 ) H_{out}=floor((H_{in}+2padding[0]-dilation[0](kernerl_size[0]-1)-1)/stride[0]+1) Hout=floor((Hin+2padding[0]−dilation[0](kernerlsize[0]−1)−1)/stride[0]+1)
W o u t = f l o o r ( ( W i n + 2 p a d d i n g [ 1 ] − d i l a t i o n [ 1 ] ( k e r n e r l s i z e [ 1 ] − 1 ) − 1 ) / s t r i d e [ 1 ] + 1 ) W_{out}=floor((W_{in}+2padding[1]-dilation[1](kernerl_size[1]-1)-1)/stride[1]+1) Wout=floor((Win+2padding[1]−dilation[1](kernerlsize[1]−1)−1)/stride[1]+1)
装置卷积:
nn.ConvTranspose2d(
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
output_padding=0,
groups=1,
bias=True,
dilation=1)
以上是关于Pytorch重要函数(nn.Conv2d;nn.ConvTranspose2d)的主要内容,如果未能解决你的问题,请参考以下文章
Pytorch一文搞懂nn.Conv2d的groups参数的作用