torch.copysign
function copysign(input: Tensor, other: Tensor, options?: BinaryOptions): TensorReturns a tensor with the magnitude of input and the sign of other element-wise.
Parameters
inputTensor- Input tensor (magnitudes)
otherTensor- Tensor whose signs to copy
optionsBinaryOptionsoptional- Optional settings including
outparameter
Returns
Tensor– A new tensor with magnitudes from input and signs from otherExamples
const mag = torch.tensor([1.0, 2.0, 3.0]);
const sign = torch.tensor([-1.0, 1.0, -1.0]);
torch.copysign(mag, sign); // [-1.0, 2.0, -3.0]