W3cubDocs

/TensorFlow 2.3

tf.keras.backend.shape

View source on GitHub

Returns the symbolic shape of a tensor or variable.

Arguments
x A tensor or variable.
Returns
A symbolic shape (which is itself a tensor).

Examples:

val = np.array([[1, 2], [3, 4]])
kvar = tf.keras.backend.variable(value=val)
tf.keras.backend.shape(kvar)
<tf.Tensor: shape=(2,), dtype=int32, numpy=array([2, 2], dtype=int32)>
input = tf.keras.backend.placeholder(shape=(2, 4, 5))
tf.keras.backend.shape(input)
<tf.Tensor 'Shape_...' shape=(3,) dtype=int32>

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/keras/backend/shape