mindspore.Tensor.new_zeros
- Tensor.new_zeros(size, dtype=None) Tensor[source]
Return a tensor of size filled with zeros.
Warning
Non-backward-compatible change after version 2.9.0: parameter dtype will become keyword-only.
- Parameters
- Returns
Tensor, the shape and dtype are defined above and filled with zeros.
- Raises
TypeError – If size is neither an int nor a tuple/list of int.
TypeError – If dtype is not a MindSpore dtype.
ValueError – If size contains negative values.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore >>> from mindspore import Tensor >>> x = Tensor((), mindspore.int32) >>> x.new_zeros((2, 3)) Tensor(shape=[2, 3], dtype=Int32, value= [[0, 0, 0], [0, 0, 0]])