LoginSignup
1
0

More than 3 years have passed since last update.

【pytorch】max_pool2dしてmax_unpool2dする意味ってなんだろう?

Last updated at Posted at 2020-11-12

背景

encoderとdecoderのネットワークでmax_poolしてからmax_unpoolしてるのを見て、これは一体なんの意味があるのか気になったので実験してみた

実験

test code

x_4, indices_4 = F.max_pool2d(x_42, kernel_size=2, stride=2, return_indices=True)
x_4d = F.max_unpool2d(x_4, indices_4, kernel_size=2, stride=2, output_size=dim_4)
print("x_4d.shape=",x_4d.shape)
print("x_42.shape=",x_42.shape)

save_image(x_4d[0,0,:,:],"x_4d.png")
save_image(x_42[0,0,:,:],"x_42.png")

output

x_4d.shape= (8, 512, 14, 14)
x_42.shape= (8, 512, 14, 14)

結果

x_4d[0,0,:,:]
image.png

x_42[0,0,:,:]
image.png

数字で表すとこんな感じ
image.png

結論

max poolしてmax unpoolすると、windowの中の最大値以外が0になる。
機能的には強い特徴が強調されるという事だろうか。

参考文献

1
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
1
0