1
$\begingroup$

When training a CNN one option is either to zero pad an image to make it bigger or upsample it. When should I choose each one?

What criteria is leveraged for choosing a method?

$\endgroup$
0
$\begingroup$

It depends on application.

For upsampling, Keras documentation says:

Repeats the rows and columns of the data by size[0] and size[1] respectively.

For zero padding, Keras documentation says:

This layer can add rows and columns of zeros at the top, bottom, left and right side of an image tensor.

So, imagine You have picture of sharp edge shapes, and You want to build model that could learn to distinguish them. In that case, I would likely go with UpSampling, because You would have extra data, and Your shape structure wouldn't be ruined. While, with smooth curved edges, smoothness could be ruined. In that case, I would go with ZeroPadding, because it won't touch inner data, it will only add zeros side the borders.

This is my intuition about those two functions, don't take it for granted. The best option You could do is to test both on Your sample and see the output.

$\endgroup$
0
$\begingroup$

Oh, well, let's say it depends on your task and model. For instance, in autoencoders, there are two main choices for upsampling. You can employ transposed convolution or rescaling. The better choice is the latter case due to the fact that the former can lead to checker-board artifacts. About zero padding, it is usually done in almost all CNNs if you use the same convolution which means the height and width of the output activation maps should be equal to the size of their input counterparts. Zero padding is usually done when you want to extract features from inputs with conv layers. The main reason we use zero padding is that the boundary locations in the inputs of the conv layers affect more entries in the output activation map.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.