tf.keras.layers.ZeroPadding2D

Zero-padding layer for 2D input (e.g. picture).

Inherits From: Layer, Module

Used in the notebooks

Used in the guide Used in the tutorials

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

Examples:

input_shape = (1, 1, 2, 2)
x = np.arange(np.prod(input_shape)).reshape(input_shape)
print(x)
[[[[0 1]
   [2 3]]]]
y = tf.keras.layers.ZeroPadding2D(padding=1)(x)
print(y)