mindspore.ops.full

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

Create a tensor filled with a specified value.

Note

fill_value 's data type not support complex numbers.

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

  • fill_value (number.Number) – The value specified.

Keyword Arguments

dtype (mindspore.dtype) – The data type specified. Default None .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> mindspore.ops.full((2, 3), 1.2)
Tensor(shape=[2, 3], dtype=Int64, value=
[[1, 1, 1],
 [1, 1, 1]])
>>> mindspore.ops.full((2, 3), 1.2, dtype=mindspore.float32)
Tensor(shape=[2, 3], dtype=Float32, value=
[[ 1.20000005e+00,  1.20000005e+00,  1.20000005e+00],
 [ 1.20000005e+00,  1.20000005e+00,  1.20000005e+00]])