mxnet.ndarray.maximum¶
-
mxnet.ndarray.
maximum
(lhs, rhs)[source]¶ Returns element-wise maximum of the input arrays with broadcasting.
Equivalent to
mx.nd.broadcast_maximum(lhs, rhs)
.Note
If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape.
- Parameters
lhs (scalar or mxnet.ndarray.array) – First array to be compared.
rhs (scalar or mxnet.ndarray.array) – Second array to be compared. If
lhs.shape != rhs.shape
, they must be broadcastable to a common shape.
- Returns
The element-wise maximum of the input arrays.
- Return type
Examples
>>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> mx.nd.maximum(x, 2).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> mx.nd.maximum(x, y).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.maximum(y, z).asnumpy() array([[ 0., 1.], [ 1., 1.]], dtype=float32)