mindspore.ops.ZerosLike

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

Creates a new tensor. All elements value are 0.

Returns a tensor of zeros with the same shape and data type as the input tensor.

Inputs:
  • input_x (Tensor) - Input tensor.

Outputs:

Tensor, has the same shape and data type as input_x but filled with zeros.

Raises

TypeError – If input_x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> zeroslike = ops.ZerosLike()
>>> x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32))
>>> output = zeroslike(x)
>>> print(output)
[[0. 0.]
 [0. 0.]]