mindspore.ops.OnesLike

class mindspore.ops.OnesLike[source]

Returns a Tensor with a value of 1 and its shape and data type is the same as the input.

Refer to mindspore.ops.ones_like() for more detail.

Supported Platforms:

Ascend GPU CPU

Examples

>>> oneslike = ops.OnesLike()
>>> input_x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32))
>>> output = oneslike(input_x)
>>> print(output)
[[1 1]
 [1 1]]