I have a tensor with the following shape:
> tf.Tensor: shape=(1, 1440)
How do I reduce such a shape so that I can get the following:
> tf.Tensor: shape=(1440,)
CodePudding user response:
Use tf.squeeze
:
import tensorflow as tf
tensor = tf.random.uniform((1, 1440))
print(tensor.shape
TensorShape([1, 1440])
And now:
squeezed = tf.squeeze(tensor)
print(squeezed.shape)
TensorShape([1440])
If you really want the comma format for the shape, turn it to NumPy:
tf.squeeze(s).numpy().shape
(1440,)