ivy.zeros(shape, *, dtype=None, device=None, out=None)[source]#

Return a new array having a specified shape and filled with zeros.

  • shape (Union[Shape, NativeShape]) – output array shape.

  • dtype (Optional[Union[Dtype, NativeDtype]]) – output array data type. If dtype is None, the output array data type must (default: None) be the default floating-point data type. Default None.

  • device (Optional[Union[Device, NativeDevice]]) – device on which to place the created array. Default: None. (default: None)

  • out (Optional[Array]) – optional output array, for writing the result to. It must have a shape that the (default: None) inputs broadcast to.

Return type:



ret – an array containing zeros.

This function conforms to the Array API Standard. This docstring is an extension of the docstring # noqa in the standard.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts ivy.Container instances in place of any of the arguments.


With ivy.NativeShape input: >>> shape = (3, 5) >>> x = ivy.zeros(shape) >>> print(x) ivy.array([[0., 0., 0., 0., 0.],

[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.]])

>>> x = ivy.zeros(5)
>>> print(x)
ivy.array([0., 0., 0., 0., 0.])