ZeroPadding2D, shape

Hi All

I have a input layer and I am trying to do zero padding to make it a specific dimension of TensorShape([1, 1, 104, 24])

import tensorflow as tf
import dumpy as np

input_shape = (1, 1, 1, 24)
x = np.arange(np.prod(input_shape)).reshape(input_shape) # (1, 1, 1, 24)
y = tf.keras.layers.ZeroPadding2D(padding=(0, 51))(x)
y.shape # TensorShape([1, 1, 103, 24])

# how do I make the y.shape --> [1, 1, 104, 24]??

How do I change the param of the y so that I can have a shape of [1,1,104, 24]???

Hi @kjewqr123
I’m not sure it is padding obtained is the one you want (you didn’t say a word about your purpose/model) , but you can get the output shape you require as follows:

input_shape = (1, 1, 1, 24)
x = np.arange(np.prod(input_shape)).reshape(input_shape) # (1, 1, 1, 24)
y = tf.keras.layers.ZeroPadding2D(padding=((0, 0),(0, 103)))(x)
y.shape # TensorShape([1, 1, 104, 24])