Table of Contents
Shortcuts

# torch.reciprocal

torch.reciprocal(input, *, out=None) → Tensor

  Returns a new tensor with the reciprocal of the elements of `input`

  out i=1 input i\text{out}_{i} = \frac{1}{\text{input}_{i}} out i​=input i​1​

  Note

  Unlike NumPy’s reciprocal, torch.reciprocal supports integral inputs. Integral inputs to reciprocal are automatically promoted to the default scalar type.

  Parameters:

    input (Tensor) – the input tensor.

  Keyword Arguments:

    out (Tensor, optional) – the output tensor.

  Example:

      >>> a = torch.randn(4)
      >>> a
      tensor([-0.4595, -2.1219, -1.4314,  0.7298])
      >>> torch.reciprocal(a)
      tensor([-2.1763, -0.4713, -0.6986,  1.3702])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.