mxnet.np.subtract¶
-
subtract
(x1, x2, out=None, **kwargs)¶ Subtract arguments element-wise.
- Parameters
x2 (x1,) – The arrays to be subtracted from each other. If x1.shape != x2.shape, they must be broadcastable to a common shape (which may be the shape of one or the other).
out (ndarray) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.
- Returns
subtract (ndarray or scalar) – The difference of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
.. note:: – This operator now supports automatic type promotion. The resulting type will be determined according to the following rules: * If both inputs are of floating number types, the output is the more precise type. * If only one of the inputs is floating number type, the result is that type. * If both inputs are of integer types (including boolean), not supported yet.
Examples
>>> np.subtract(1.0, 4.0) -3.0 >>> x1 = np.arange(9.0).reshape((3, 3)) >>> x2 = np.arange(3.0) >>> np.subtract(x1, x2) array([[0., 0., 0.], [3., 3., 3.], [6., 6., 6.]])