normalize_padding_size¶

normalize_padding_size(padding)[source]¶

Normalizes padding to be length 4 (left, top, right, bottom).

Given a scalar value, this is assumed to apply to all sides and therefore repeated for each output (left, right, top, bottom). A length 2 input is assumed to apply the same padding to the left/right and top/bottom.

Parameters:

padding (int or tuple(int)) – Padding to normalize.

Raises:
  • ValueError – Invalid input size of padding (e.g. length 3).

  • ValueError – Invalid input shape of padding (e.g. 3 dimensional).

Returns:

Numpy array of length 4 with elements containing padding for left, top, right, bottom.

Return type:

numpy.ndarray