Table Of Contents
Table Of Contents


mxnet.ndarray.broadcast_like(lhs=None, rhs=None, out=None, name=None, **kwargs)

Broadcasts lhs to have the same shape as rhs.

Broadcasting is a mechanism that allows NDArrays to perform arithmetic operations with arrays of different shapes efficiently without creating multiple copies of arrays. Also see, Broadcasting for more explanation.

Broadcasting is allowed on axes with size 1, such as from (2,1,3,1) to (2,8,3,9). Elements will be duplicated on the broadcasted axes.

For example:

broadcast_like([[1,2,3]], [[5,6,7],[7,8,9]]) = [[ 1.,  2.,  3.],
                                                [ 1.,  2.,  3.]])

Defined in src/operator/tensor/

  • lhs (NDArray) – First input.
  • rhs (NDArray) – Second input.
  • out (NDArray, optional) – The output NDArray to hold the result.

out – The output of this function.

Return type:

NDArray or list of NDArrays