pypose.pm¶
- class pypose.pm(input)[source]¶
Returns plus or minus (\(\pm\)) states for tensor.
- Parameters:
input (
Tensor
) – the input tensor.- Returns:
the output tensor contains only \(-1\) or \(+1\).
- Return type:
Tensor
Note
The
pm()
function is different fromtorch.sign()
, which returns \(0\) for zero inputs, it will return \(+1\) if an input element is zero.Example
>>> pp.pm(torch.tensor([0.1, 0, -0.2])) tensor([ 1., 1., -1.]) >>> pp.pm(torch.tensor([0.1, 0, -0.2], dtype=torch.float64)) tensor([ 1., 1., -1.], dtype=torch.float64)