[ 组合替代实现 ]torch.copysign

torch.copysign

torch.copysign(input,
          other,
          *,
          out=None)

创建一个新的浮点张量,其大小与input相同,正负符号与other相同

PaddlePaddle 目前无对应 API,可使用如下代码组合替代实现:

转写示例

out:指定输出

# Pytorch 写法
torch.copysign(input, other, out=y)

# Paddle 写法
paddle.assign(paddle.abs(input) * paddle.sign(other), y)