mindspore.mint.zeros

View Source On AtomGit
mindspore.mint.zeros(size, *, dtype=None)[source]

Creates a tensor of shape size filled with zeros of type dtype.

Parameters:

size (Union[tuple[int], list[int], int, Tensor]) – The specified shape of output tensor. Only positive integers, tuples, or Tensors containing positive integers are allowed. If it is a Tensor, it must be a 0-D or 1-D Tensor with int32 or int64 dtypes.

Keyword Arguments:

dtype (mindspore.dtype, optional) – The specified type of output tensor. If dtype is None , mindspore.float32 will be used. Default: None .

Returns:

Tensor, whose dtype and size are defined by input.

Raises:

TypeError – If size is neither an int nor a tuple/list/Tensor of int.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> from mindspore import mint
>>> output = mint.zeros((2, 2), dtype=mindspore.float32)
>>> print(output)
[[0. 0.]
 [0. 0.]]