mindspore.ops.copysign
- mindspore.ops.copysign(x, other)[source]
Create a float tensor composed of the absolute values of x and the signs of other . Support broadcasting.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> # case 1: When other is a tensor >>> x = mindspore.tensor([[0.3, -0.7], ... [0.5, 0.5]]) >>> other = mindspore.tensor([-0.4, 0.6]) >>> output = mindspore.ops.copysign(x, other) >>> print(output) [[-0.3 0.7] [-0.5 0.5]] >>> # case 2: When other is a scalar >>> output = mindspore.ops.copysign(x, 2) >>> print(output) [[0.3 0.7] [0.5 0.5]]