class torch.nn.Conv2d(
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
dilation=1,
groups=1,
bias=True)
输入: (N,C_in,L_in)
输出: (N,C_out,L_out)
输入输出的计算方式:
L
o
u
t
=
f
l
o
o
r
(
(
L
i
n
+
2
p
a
d
d
i
n
g
−
d
i
l
a
t
i
o
n
(
k
e
r
n
e
r
l
s
i
z
e
−
1
)
−
1
)
/
s
t
r
i
d
e
+
1
)
L_{out}=floor((L_{in}+2padding-dilation(kernerl_size-1)-1)/stride+1)
Lout=floor((Lin+2padding−dilation(kernerlsize−1)−1)/stride+1)
dilation表示卷积核各个元素之间的膨胀大小,间隔大小,默认为1
class torch.nn.MaxPool2d(
kernel_size,
stride=None, #默认值是kernel_size
padding=0,
dilation=1,
return_indices=False,
ceil_mode=False)
shape:
输入: (N,C,H_{in},W_in)
输出: (N,C,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
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](kernel_size[0] - 1) - 1)/stride[0] + 1
Hout=floor((Hin+2padding[0]−dilation[0](kernelsize[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 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](kernel_size[1] - 1) - 1)/stride[1] + 1 Wout=floor((Win+2padding[1]−dilation[1](kernelsize[1]−1)−1)/stride[1]+1