Understanding of parameter padding in tensorflow.conv2d convolution function

The parameter of padding can choose "VALID" or "SAME"

 Enter a matrix of width W*W, the size of the convolution kernel is F*F, and the step size is S

The first case: padding="VALID", the edge of the matrix is ​​not filled with zeros, at this time the last column or columns may be discarded, and the last row or rows depends on the convolution kernel and step size you define. After the convolution kernel, the output matrix size is

(Improvement arrangement)

The second case: padding="SAME", the edge of the matrix is ​​filled with zeros (the zero-filling does not destroy the original image pixels), tensorflow will automatically fill in zeros, you do not need to define it yourself, the output matrix size after the convolution kernel is

out=W/S (round up)

Suppose now that a matrix of width W: is input, the size of the convolution kernel is F: , the step size is S: 4 , and the output matrix size is

When padding='VALID', out=(227-11+1)/4=55, so the size of the output matrix is ​​55*55

When padding="SAME", out=227/4=57, so the size of the output matrix is ​​57*57






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325978189&siteId=291194637