mxnet.ndarray.greater¶

mxnet.ndarray.greater(lhs, rhs)[source]

Returns the result of element-wise greater than (>) comparison operation with broadcasting.

For each element in input arrays, return 1(true) if lhs elements are greater than rhs, otherwise return 0(false).

Equivalent to lhs > rhs and mx.nd.broadcast_greater(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

Output array of boolean values.

Return type

NDArray

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)
>>> (x > 1).asnumpy()
array([[ 0.,  0.,  0.],
[ 0.,  0.,  0.]], dtype=float32)
>>> (x > y).asnumpy()
array([[ 1.,  1.,  1.],
[ 0.,  0.,  0.]], dtype=float32)
>>> mx.nd.greater(x, y).asnumpy()
array([[ 1.,  1.,  1.],
[ 0.,  0.,  0.]], dtype=float32)
>>> (z > y).asnumpy()
array([[ 0.,  1.],
[ 0.,  0.]], dtype=float32)