tf.broadcast_static_shape
Stay organized with collections
Save and categorize content based on your preferences.
Computes the shape of a broadcast given known shapes.
tf.broadcast_static_shape(
shape_x, shape_y
)
When shape_x
and shape_y
are fully known TensorShape
s this computes a
TensorShape
which is the shape of the result of a broadcasting op applied in
tensors of shapes shape_x
and shape_y
.
For example, if shape_x is TensorShape([1, 2, 3])
and shape_y is
TensorShape([5, 1, 3])
, the result is a TensorShape whose value is
TensorShape([5, 2, 3])
.
This is useful when validating the result of a broadcasting operation when the
tensors have statically known shapes.
Example:
shape_x = tf.TensorShape([1, 2, 3])
shape_y = tf.TensorShape([5, 1 ,3])
tf.broadcast_static_shape(shape_x, shape_y)
TensorShape([5, 2, 3])
Args |
shape_x
|
A TensorShape
|
shape_y
|
A TensorShape
|
Returns |
A TensorShape representing the broadcasted shape.
|
Raises |
ValueError
|
If the two shapes can not be broadcasted.
|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.broadcast_static_shape\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/array_ops.py#L560-L593) |\n\nComputes the shape of a broadcast given known shapes.\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.broadcast_static_shape`](https://www.tensorflow.org/api_docs/python/tf/broadcast_static_shape)\n\n\u003cbr /\u003e\n\n tf.broadcast_static_shape(\n shape_x, shape_y\n )\n\nWhen `shape_x` and `shape_y` are fully known `TensorShape`s this computes a\n`TensorShape` which is the shape of the result of a broadcasting op applied in\ntensors of shapes `shape_x` and `shape_y`.\n\nFor example, if shape_x is `TensorShape([1, 2, 3])` and shape_y is\n`TensorShape([5, 1, 3])`, the result is a TensorShape whose value is\n`TensorShape([5, 2, 3])`.\n\nThis is useful when validating the result of a broadcasting operation when the\ntensors have statically known shapes.\n\n#### Example:\n\n shape_x = tf.TensorShape([1, 2, 3])\n shape_y = tf.TensorShape([5, 1 ,3])\n tf.broadcast_static_shape(shape_x, shape_y)\n TensorShape([5, 2, 3])\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------|-----------------|\n| `shape_x` | A `TensorShape` |\n| `shape_y` | A `TensorShape` |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `TensorShape` representing the broadcasted shape. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-------------------------------------------|\n| `ValueError` | If the two shapes can not be broadcasted. |\n\n\u003cbr /\u003e"]]