padding strategy conv tensorflow

Solutions on MaxInterview for padding strategy conv tensorflow by the best coders in the world

showing results for - "padding strategy conv tensorflow"
Lilly
17 Nov 2017
1# SAME Scheme
2if (input_height % strides[1] == 0):
3    pad_along_height = max(filter_height - strides[1], 0)
4else:
5    pad_along_height = max(filter_height - (input_height % strides[1]), 0)
6if (input_width % strides[2] == 0):
7    pad_along_width = max(filter_width - strides[2], 0)
8else:
9    pad_along_width = max(filter_width - (input_width % strides[2]), 0)
10    
11print("pad along height and width...")
12print("pad along height: {}".format(pad_along_height))
13print("pad along width: {}".format(pad_along_width))
14pad_top = pad_along_height // 2 # divied by 2
15pad_bottom = pad_along_height - pad_top
16pad_left = pad_along_width // 2
17pad_right = pad_along_width - pad_left    
18
19print("Padding size on top, bottom, left and right")
20print("top: {}".format(pad_top))
21print("bottom: {}".format(pad_bottom))
22print("left: {}".format(pad_left))
23print("right: {}".format(pad_right))