Reputation: 1129
Tensorflow functions seem to use only zeroes for padding (for example, the tf.nn.conv2d
function).
Is there an easy way (that requires minimal changes in existing code) to run the same functions with paddings of 1s or any other arbitrary numbers instead of zeroes?
Upvotes: 0
Views: 55
Reputation: 5162
The easiest way would be to change the padding in conv2d from "SAME" to "VALID" and perform the padding yourself.
img = tf.ones([img_height+padding,img_width+padding, channels])
img[padding//2:img_height, padding//2:img_width] = old_img
result = conv2d(img, kernel, padding="VALID")
Upvotes: 1