mxnet.np.zeros

zeros(shape, dtype=None, order='C', device=None)

Return a new array of given shape and type, filled with zeros. This function currently only supports storing multi-dimensional data in row-major (C-style).

Parameters
  • shape (int or tuple of int) – The shape of the empty array.

  • dtype (str or numpy.dtype, optional) – An optional value type, When npx.is_np_default_dtype() returns False, default dtype is float32, When npx.is_np_default_dtype() returns True, default dtype is float64. Note that this behavior is different from NumPy’s zeros function where float64 is the default value, here we can set ‘float32’ or ‘float64’ as your default dtype, because float32 is considered as the default data type in deep learning.

  • order ({'C'}, optional, default: 'C') – How to store multi-dimensional data in memory, currently only row-major (C-style) is supported.

  • device (Device, optional) – Device context on which the memory is allocated. Default is mxnet.device.current_device().

Returns

out – Array of zeros with the given shape, dtype, and device.

Return type

ndarray

Examples

>>> np.zeros(5)
array([0., 0., 0., 0., 0.])
>>> np.zeros((5,), dtype=int)
array([0, 0, 0, 0, 0], dtype=int64)
>>> np.zeros((2, 1))
array([[0.],
       [0.]])