# tfc.ops.same_padding_for_kernel

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/compression/blob/v2.14.1/tensorflow_compression/python/ops/padding_ops.py#L22-L51) |

Determine correct amount of padding for `same` convolution.

#### View aliases


**Main aliases**

[`tfc.same_padding_for_kernel`](https://www.tensorflow.org/api_docs/python/tfc/ops/same_padding_for_kernel)

<br />

    tfc.ops.same_padding_for_kernel(
        shape, corr, strides_up=None
    )

To implement `'same'` convolutions, we first pad the image, and then perform a
`'valid'` convolution or correlation. Given the kernel shape, this function
determines the correct amount of padding so that the output of the convolution
or correlation is the same size as the pre-padded input.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `shape` | Shape of the convolution kernel (without the channel dimensions). |
| `corr` | Boolean. If `True`, assume cross correlation, if `False`, convolution. |
| `strides_up` | If this is used for an upsampled convolution, specify the strides here. (For downsampled convolutions, specify `(1, 1)`: in that case, the strides don't matter.) |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The amount of padding at the beginning and end for each dimension. ||

<br />