1. 當padding 為VALID時:
輸出寬和高的公式代碼為:
output_width = (input_width - filter_width + 1) / strides_width; (結果向上取整)
output_height = (input_height - filter_height + 1) / strides_height; (結果向上取整)
2.當padding 為SAME時:
輸出寬和高與filter的寬高沒有關系,只與步長的寬高有關系:
output_width = input_width / strides_width; (結果向上取整)
output_height = input_height / strides_height; (結果向上取整)
3. 補零規則:
pad_height = max((output_height - 1) * strides_height + filter_height - in_height , 0);
pad_width = max((out_width - 1) * strides_width +filter_width - in_width, 0);
pad_top = pad_height / 2;
pad_bottom = pad_height - pad_top;
pad_left = pad_width / 2;
pad_right = pad_width - pad_left;
pad_top,pad_bottom,pad_left,pad_right為補零的行數和列數。
或者:最簡公式
valid: [(n-f)/s + 1] x [(n-f)/s + 1]; 該公式向下取整
same: [(n + 2p -f)/s +1] x [(n + 2p -f)/s +1]; 該公式向下取整