mindspore.mint.full

View Source On Gitee
mindspore.mint.full(size, fill_value, *, dtype=None)[source]

Create a Tensor of the specified shape and fill it with the specified value.

Parameters
  • size (Union(tuple[int], list[int])) – The specified shape of output tensor.

  • fill_value (Union(number.Number, Tensor)) – Value to fill the returned tensor. It can be a Scalar number, a 0-D Tensor, or a 1-D Tensor with only one element.

Keyword Arguments

dtype (mindspore.dtype) – The specified type of output tensor. bool_ and number are supported, for details, please refer to mindspore.dtype . Default: None .

Returns

Tensor.

Raises
  • TypeError – If size is not a tuple or list.

  • ValueError – The element in size is less than 0.

Supported Platforms:

Ascend

Examples

>>> from mindspore import mint
>>> output = mint.full((2, 2), 1)
>>> print(output)
[[1. 1.]
 [1. 1.]]
>>> output = mint.full((3, 3), 0)
>>> print(output)
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]