Pytorch:Conv2d卷积前后尺寸

Pytorch卷积前后的尺寸大小

      • 1. Conv2d参数
      • 2. 尺寸变化
      • 3. 示例

1. Conv2d参数

Pytorch:Conv2d卷积前后尺寸_第1张图片

2. 尺寸变化

卷积前的尺寸为(N,C,W,H) ,卷积后尺寸为(N,F,W_n,H_n)
W_n = (W-F+S+2P)/S 向下取整
H_n = (H-F+S+2P)/S

3. 示例

# m = nn.Conv2d(16, 33, 3, stride=2)
# non-square kernels and unequal stride and with padding
m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
# non-square kernels and unequal stride and with padding and dilation
# m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
input = torch.randn(20, 16, 50, 100)
print(input.size())
output = m(input)
print(output.size())

你可能感兴趣的:(Pytorch,pytorch)