mxnet.np.add¶
-
add
(x1, x2, out=None, **kwargs)¶ Add arguments element-wise.
- Parameters
x2 (x1,) – The arrays to be added. 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
The sum 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.add(1.0, 4.0) 5.0 >>> >>> x1 = np.arange(9.0).reshape((3, 3)) >>> x2 = np.arange(3.0) >>> np.add(x1, x2) array([[ 0., 2., 4.], [ 3., 5., 7.], [ 6., 8., 10.]])