mindspore.ops.ones_like
- mindspore.ops.ones_like(input, *, dtype=None)[source]
Return a tensor filled with 1, with the same size as input.
- Parameters
input (Tensor) – The input tensor.
- Keyword Arguments
dtype (
mindspore.dtype
, optional) – The data type specified. DefaultNone
represents the same data type as the input.- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> input = mindspore.ops.arange(4) >>> mindspore.ops.ones_like(input) Tensor(shape=[4], dtype=Int64, value= [1, 1, 1, 1])