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]], default: None) – output array data type. If dtype is None, the output array data type must be the default floating-point data type. Default None.

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

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the 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 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.])