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]?
You are using:
padding = (0, 51)
This means: (symmetric_height_pad, symmetric_width_pad). I.e. you are adding 51 zeros to left and right to you number, hence you get 51 + 1 + 51 = 103 items. To get 104, you can add for example 51 to left and 52 to right using:
padding=((0, 0), (51, 52))
Here the numbers mean: ((top_pad, bottom_pad), (left_pad, right_pad))