zeros¶
-
zeros(shape, dtype=<class 'numpy.float32'>, order='C', ctx=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 (default is numpy.float32). Note that this behavior is different from NumPy’s zeros function where float64 is the default value, 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.
- ctx : Context, optional
An optional device context (default is the current default context).
Returns: - out : ndarray
Array of zeros with the given shape, dtype, and ctx.
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.]])