mindspore.Tensor.new_full
- Tensor.new_full(size, fill_value, *, dtype=None) Tensor [source]
Return a tensor of size filled with fill_value.
- Parameters
- Keyword Arguments
dtype (
mindspore.dtype
, optional) – The desired data type of returned Tensor. If None, the returned tensor has the same dtype as self. Default:None
.- Returns
Tensor, the shape and dtype is defined above and filled with fill_value.
- Raises
TypeError – If size is not a tuple or list of int.
TypeError – If dtype is not a MindSpore dtype.
ValueError – If size contains negative values.
- Supported Platforms:
Ascend
Examples
>>> from mindspore import Tensor >>> x = Tensor([1, 2, 3, 4], mindspore.int32) >>> output = x.new_full((2, 3), 3) >>> print(output) [[3 3 3] [3 3 3]]