0

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]?

halfer
  • 19,824
  • 17
  • 99
  • 186
kuku
  • 281
  • 2
  • 5
  • 12
  • Ideally, please write your titles as a full summary of the problem, not just the theme (and definitely not "please help me". This helps other readers to decide what they click on based on their areas of expertise. – halfer Feb 08 '23 at 20:13

1 Answers1

1

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))