tf.keras.backend.shape
Stay organized with collections
Save and categorize content based on your preferences.
Returns the symbolic shape of a tensor or variable.
tf.keras.backend.shape(
x
)
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>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.backend.shape\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/backend/shape) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/python/keras/backend.py#L1157-L1178) |\n\nReturns the symbolic shape of a tensor or variable.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.backend.shape`](/api_docs/python/tf/keras/backend/shape)\n\n\u003cbr /\u003e\n\n tf.keras.backend.shape(\n x\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|-----|-----------------------|\n| `x` | A tensor or variable. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A symbolic shape (which is itself a tensor). ||\n\n\u003cbr /\u003e\n\n#### Examples:\n\n val = np.array([[1, 2], [3, 4]])\n kvar = tf.keras.backend.variable(value=val)\n tf.keras.backend.shape(kvar)\n \u003ctf.Tensor: shape=(2,), dtype=int32, numpy=array([2, 2], dtype=int32)\u003e\n input = tf.keras.backend.placeholder(shape=(2, 4, 5))\n tf.keras.backend.shape(input)\n \u003ctf.Tensor 'Shape_...' shape=(3,) dtype=int32\u003e"]]