Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.copysign function

PyTorch torch.copysign function

PyTorch torch.copysign function


PyTorch torch reference manual 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

)

print

(

result

)

 

tensor([-1., -2., 3., -4.])


PyTorch torch reference manual PyTorch torch reference manual