본문 바로가기
파이썬

파이썬 What is the difference between 'SAME' and 'VALID' padding in tf.nn.max_pool of tensorflow?

by º기록 2020. 11. 3.
반응형

tensorflow tf.nn.max_pool 에서 'SAME'패딩과 'VALID'패딩의 차이점은 무엇입니까?

제 생각에는 'VALID'는 최대 풀을 할 때 가장자리 외부에 제로 패딩이 없음을 의미합니다.


 

해결 방법

 

더 명확하게하기 위해 예를 들어 보겠습니다.

출력 모양은 다음과 같습니다.

x = tf.constant([[1., 2., 3.],
                 [4., 5., 6.]])

x = tf.reshape(x, [1, 2, 3, 1])  # give a shape accepted by tf.nn.max_pool

valid_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='VALID')
same_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME')

valid_pad.get_shape() == [1, 1, 1, 1]  # valid_pad is [5.]
same_pad.get_shape() == [1, 1, 2, 1]   # same_pad is  [5., 6.]

 

참조 페이지 https://stackoverflow.com/questions/37674306

 

 

반응형

댓글