mindspore.ops.full
- mindspore.ops.full(size, fill_value, *, dtype=None)[源代码]
创建tensor,用指定值填充。
说明
fill_value 不支持复数类型。
- 参数:
size (Union(tuple[int], list[int])) - 指定的shape。
fill_value (number.Number) - 指定值。
- 关键字参数:
dtype (mindspore.dtype) - 指定的数据类型。默认
None
。
- 返回:
Tensor
- 支持平台:
Ascend
GPU
CPU
样例:
>>> 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]])