mxnet.ndarray.broadcast_like¶
-
mxnet.ndarray.
broadcast_like
(lhs=None, rhs=None, lhs_axes=_Null, rhs_axes=_Null, 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.]]) broadcast_like([9], [1,2,3,4,5], lhs_axes=(0,), rhs_axes=(-1,)) = [9,9,9,9,9]
Defined in src/operator/tensor/broadcast_reduce_op_value.cc:L315
- Parameters
lhs (NDArray) – First input.
rhs (NDArray) – Second input.
lhs_axes (Shape or None, optional, default=None) – Axes to perform broadcast on in the first input array
rhs_axes (Shape or None, optional, default=None) – Axes to copy from the second input array
out (NDArray, optional) – The output NDArray to hold the result.
- Returns
out – The output of this function.
- Return type
NDArray or list of NDArrays