mindspore.ops.Fill
- class mindspore.ops.Fill[source]
Creates a tensor filled with a scalar value.
Creates a tensor with shape described by the first argument and fills it with values in the second argument.
- Inputs:
type (mindspore.dtype) - The specified type of output tensor. Only constant value is allowed.
shape (tuple) - The specified shape of output tensor. Only constant value is allowed.
value (scalar) - Value to fill the returned tensor. Only constant value is allowed.
- Outputs:
Tensor, has the same type and shape as input value.
- Raises
TypeError – If shape is not a tuple.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> fill = ops.Fill() >>> output = fill(mindspore.float32, (2, 2), 1) >>> print(output) [[1. 1.] [1. 1.]] >>> output = fill(mindspore.float32, (3, 3), 0) >>> print(output) [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]]