A. Cimet
A. Cimet

Reputation: 87

Filter size and stride when upsampling image using Conv2D Transpose

I am using Conv2D Transpose to upsample image by factors 18, 9, 6, 3. My images are of sizes (1,1), (2,2), (3,3), (6,6). The goal is to upsample them to size (18,18).

The problem I am having is when choosing the correct filter size, stride and padding to achieve this. I have read articles about checkboard patterns that might arise when using improper sizes, but I still have not found any solution about which sizes to choose.

For the image (1,1) -> (18,18), I have chosen the filter size of (18,18) with no stride and padding. This makes sense to me as this one pixel is solely responsible for the look of the entire upsampled image.

But the other three are giving me problems. One solution that I have thought of is that for (2,2) -> (18,18), I use the filter size (9,9) with stride (9,9). This would result that each pixel (2,2) provides 9,9 upsampled pixels.

Is this a proper way or would you recommend something else.

Upvotes: 0

Views: 736

Answers (1)

tilman151
tilman151

Reputation: 634

Have a look at the Keras docs. You can find the formula to calculate the output shape there:

new_rows = ((rows - 1) * strides[0] + kernel_size[0] - 2 * padding[0] + output_padding[0])
new_cols = ((cols - 1) * strides[1] + kernel_size[1] - 2 * padding[1] + output_padding[1])

Upvotes: 1

Related Questions