qml.math.get_batch_size

get_batch_size(tensor, expected_shape, expected_size)[source]

Determine whether a tensor has an additional batch dimension for broadcasting, compared to an expected_shape. Has support for abstract TF tensors.

Parameters
  • tensor (TensorLike) – A tensor to inspect for batching

  • expected_shape (Tuple[int]) – The expected shape of the tensor if not batched

  • expected_size (int) – The expected size of the tensor if not batched

Returns

The batch size of the tensor if there is one, otherwise None

Return type

Optional[int]

Contents

Using PennyLane

Release news

Development

API

Internals