Shortcuts

torch.true_divide

torch.true_divide(dividend, divisor) → Tensor

Performs “true division” that always computes the division in floating point. Analogous to division in Python 3 and equivalent to torch.div() except when both inputs have bool or integer scalar types, in which case they are cast to the default (floating) scalar type before the division.

outi=dividendidivisor\text{out}_i = \frac{\text{dividend}_i}{\text{divisor}}
Parameters
  • dividend (Tensor) – the dividend

  • divisor (Tensor or Scalar) – the divisor

Keyword Arguments

out (Tensor, optional) – the output tensor.

Example:

>>> dividend = torch.tensor([5, 3], dtype=torch.int)
>>> divisor = torch.tensor([3, 2], dtype=torch.int)
>>> torch.true_divide(dividend, divisor)
tensor([1.6667, 1.5000])
>>> torch.true_divide(dividend, 2)
tensor([2.5000, 1.5000])

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