PyTorch torch.copysign function
PyTorch torch reference manual
torch.copysign is a PyTorch function for copying the sign element-wise.
Function definition
torch.copysign(input, other, *, out=None)
Usage examples
Example
import
torch
Sign-copy example
x
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
,
4.0
]
)
y
=
torch.
tensor
(
[
1.0
,
1.0
,
1.0
,
1.0
]
)
result
=
torch.
copysign
(
x
,
y
)
(
result
)