LoginSignup
0
0

More than 3 years have passed since last update.

CNNの畳み込み層のinputとoutputのshapeの変換式のメモ

Posted at

CNNの畳み込み層での変換によってFeature mapsがどう変換されるのか分からなかったので調べた.

結論

普段pytorchを使用するので,pytorchのドキュメントを調べたら書いてあった.導出もできれば良かったが,今回は結果だけわかれば良かったのでまたいつか.

$$
H_{out} = \left\lfloor\frac{H_{in} + 2 \times \text{padding}[0] - \text{dilation}[0] \times (\text{kernel_size}[0] − 1) − 1}{\text{stride}[0]} + 1\right\rfloor
$$

$$
W_{out} = \left\lfloor\frac{W_{in} + 2 \times \text{padding}[1] - \text{dilation}[1] \times (\text{kernel_size}[1] - 1) - 1}{\text{stride}[1]} + 1\right\rfloor
$$

$H_{in}$:変換前のhight
$W_{in}$:変換前のwidth

$H_{out}$:変換後のhight
$W_{out}$:変換後のwidth

$\text{kernel_size}[0]$:hightのkernel_size(デフォルトは1)
$\text{kernel_size}[1]$:widthのkernel_size(デフォルトは1)

$\text{padding}[0]$:hightのpadding(デフォルトは0)
$\text{padding}[1]$:widthのpadding(デフォルトは0)

$\text{dilation}[0]$:hightのdilation(デフォルトは1)
$\text{dilation}[1]$:widthのdilation(デフォルトは1)

$\text{stride}[0]$:hightのstride(デフォルトは1)
$\text{stride}[1]$:widthのstride(デフォルトは1)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0