tf.broadcast_static_shape  |  TensorFlow v2.16.1 (original) (raw)

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.

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.broadcast_static_shape

tf.broadcast_static_shape(
    shape_x, shape_y
)

When shape_x and shape_y are fully known TensorShapes this computes aTensorShape 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 isTensorShape([5, 1, 3]), the result is a TensorShape whose value isTensorShape([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.