mindspore.numpy.full(shape, fill_value, dtype=None)[source]

Returns a new tensor of given shape and type, filled with fill_value.

  • shape (Union[int, tuple(int), list(int)]) – Shape of the new tensor, e.g., \((2, 3)\) or \(2\).

  • fill_value (Union[int, float, bool, list, tuple]) – Scalar or array_like fill value.

  • dtype (Union[mindspore.dtype, str], optional) – Designated tensor dtype, if dtype is None, the data type of the new tensor will be inferred from fill_value. Default is None.


Tensor, with the designated shape and dtype, filled with fill_value.

  • TypeError – If input arguments have types not specified above.

  • ValueError – If shape has entries < 0.

Supported Platforms:

Ascend GPU CPU


>>> import mindspore.numpy as np
>>> print(np.full((2,2), True))
[[True True]
[True True]]