mindspore.numpy.zeros

View Source On Gitee
mindspore.numpy.zeros(shape, dtype=mstype.float32)[source]

Returns a new tensor of given shape and type, filled with zeros.

Parameters
  • shape (Union[int, tuple, list]) – the shape of the new tensor.

  • dtype (Union[mindspore.dtype, str], optional) – Designated tensor dtype. Default is mstype.float32.

Returns

Tensor, with the designated shape and dtype, filled with zeros.

Raises
  • TypeError – If input arguments have types not specified above.

  • ValueError – If shape entries have values \(< 0\).

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> print(np.zeros((2,2)))
[[0. 0.]
[0. 0.]]