Table Of Contents
Table Of Contents


mxnet.ndarray.zeros(shape, ctx=None, dtype=None, stype=None, **kwargs)[source]

Return a new array of given shape and type, filled with zeros.

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

  • ctx (Context, optional) – An optional device context (default is the current default context)

  • dtype (str or numpy.dtype, optional) – An optional value type (default is float32)

  • stype (string, optional) – The storage type of the empty array, such as ‘row_sparse’, ‘csr’, etc.


A created array

Return type

NDArray, CSRNDArray or RowSparseNDArray


>>> mx.nd.zeros((1,2), mx.cpu(), stype='csr')
<CSRNDArray 1x2 @cpu(0)>
>>> mx.nd.zeros((1,2), mx.cpu(), 'float16', stype='row_sparse').asnumpy()
array([[ 0.,  0.]], dtype=float16)