broadcast_to¶
- dragon.- broadcast_to(
 inputs,
 shape,
 **kwargs
 )[source]¶
- Broadcast input to the given shape. - Length of - shapecould either be less or more than the number of input dimensions:- a = dragon.constant([[1], [2], [3]]) # Shape: (3, 1) -> (3, 2) print(dragon.broadcast_to(a, shape=(3, 2))) print(dragon.broadcast_to(a, shape=(2,))) # Equivalent # Shape: (3,) -> (1, 3) -> (2, 3) b = dragon.constant([1, 2, 3]) print(dragon.broadcast_to(b, shape=(2, 3))) # Wrong remapping shape: (3,) -> (6,) # Only the dimension with size 1 could broadcast print(dragon.broadcast_to(b, shape=(6,))) - Parameters:
- inputs (dragon.Tensor) – The input tensor.
- shape (Sequence[Union[int, dragon.Tensor]]) – The output shape to broadcast to.
 
 - Returns:
- dragon.Tensor – The output tensor. 
 
