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

1
  • 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. Commented Feb 8, 2023 at 20:13

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.