mindspore.numpy.full_like

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

Returns a full array with the same shape and type as a given array.

Note

Input array must have the same size across a dimension. If a is not a Tensor, dtype is float32 by default if not provided.

Parameters
  • a (Union[Tensor, list, tuple]) – The shape and data-type of a define these same attributes of the returned array.

  • fill_value (scalar) – Fill value.

  • dtype (mindspore.dtype, optional) – Overrides the data type of the result.

  • shape (int or sequence of ints, optional) – Overrides the shape of the result.

Returns

Tensor, array of fill_value with the same shape and type as a.

Raises

ValueError – if a is not a Tensor, list or tuple.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> a = np.ones((4,1,2))
>>> output = np.full_like(a, 0.5)
>>> print(output)
[[[0.5 0.5]]
[[0.5 0.5]]
[[0.5 0.5]]
[[0.5 0.5]]]