mindspore.numpy.zeros

mindspore.numpy.zeros(shape, dtype=mstype.float32)[源代码]

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

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

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

返回

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

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

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

Supported Platforms:

Ascend GPU CPU

样例

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