tf_quant_finance.utils.broadcast_tensors

Last updated: 2023-03-16.

tf_quant_finance.utils.broadcast_tensors#

View source

Broadcasts arguments to the common shape.

tf_quant_finance.utils.broadcast_tensors(
    *, name=None, *args
)

Example#

import tensorflow as tf
import tf_quant_finance as tff

args = [tf.ones([1, 2], dtype=tf.float64), tf.constant([[True], [False]])]
tff.utils.broadcast_tensor_shapes(*args)
# Expected: (array([[1., 1.], [1., 1.]]),
#            array([[True, True], [False, False]])

Args:#

  • *args: A sequence of Tensors of compatible shapes and any dtypes.

  • name: Python string. The name to give to the ops created by this function. Default value: None which maps to the default name broadcast_tensor_shapes.

Returns:#

A tuple of broadcasted Tensors. Each Tensor has the same dtype as the corresponding input Tensor.

Raises:#

  • ValueError: If inputs are of incompatible shapes.