mindspore.ops.Zeros

class mindspore.ops.Zeros(*args, **kwargs)[source]

Creates a tensor filled with value zeros.

Creates a tensor with shape described by the first argument and fills it with value zeros in type of the second argument.

Inputs:
  • shape (Union[tuple[int], int]) - The specified shape of output tensor. Only constant positive int is allowed.

  • type (mindspore.dtype) - The specified type of output tensor. Only constant value is allowed.

Outputs:

Tensor, has the same type and shape as input shape value.

Raises
  • TypeError – If shape is neither int nor tuple.

  • TypeError – If shape is a tuple whose elements are not all int.

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore.ops import operations as ops
>>> zeros = ops.Zeros()
>>> output = zeros((2, 2), mindspore.float32)
>>> print(output)
[[0. 0.]
 [0. 0.]]