# 次元の計算について, 公式サイト通りとする.
# ex.
# kernel_size = (2, 3) ならば, kernel_size[0] = 2, kernel_size[1] = 3
# kernel_size = 5 ならば, kernel_size[0] = 5, kernel_size[1] = 5
# padding = (3, 5) ならば, padding[0] = 3, padding[1] = 5
# padding = 2 ならば, padding[0] = 2, padding[1] = 2
# stride = (4, 5) ならば, stride[0] = 4, stride[1] = 5
# stride = 3 ならば, stride[0] = 3, stride[1] = 3
# dilation は, ここでは, 初期値 (1, 1) を 使用するため, dilation[0] = 1, dilation[1] = 1
# output_padding は, ここでは, 初期値 0 を 使用するため, output_padding[0] = 0, output_padding[1] = 0
# Conv2d
# Input: (N, Cin, Hin, Win)
# Output: (N, Cout, Hout, Wout)
# Hout = (Hin + 2 × padding[0] − dilation[0] × (kernel_size[0] − 1) − 1) / stride[0] + 1
# Wout = (Win + 2 × padding[1] − dilation[1] × (kernel_size[1] − 1) − 1) / stride[1] + 1
# ConvTranspose2d
# Input: (N, Cin, Hin, Win)
# Output: (N, Cout, Hout, Wout)
# Hout = (Hin − 1) × stride[0] − 2 × padding[0] + kernel_size[0] + output_padding[0]
# Wout = (Win − 1) × stride[1] − 2 × padding[1] + kernel_size[1] + output_padding[1]
# 1. Conv2d
# Input: (1, 3, 128, 128)
# Hout = (128 + 2 × 1 − 1 × (4 − 1) − 1) / 2 + 1 = 64
# Wout = (128 + 2 × 1 − 1 × (4 − 1) − 1) / 2 + 1 = 64
# Output: (1, 256, 64, 64)
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme