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

PyTorch torch.divide function

PyTorch torch.divide function

PyTorch torch.divide function


PyTorch torch reference manual PyTorch torch reference manual

torch.divide is a PyTorch function for element-wise division (equivalent to div).

Function definition

torch.divide(input, other, *, rounding_mode=None, out=None)


Usage examples

Example

import

torch

Element-wise division example

x

=

torch.

tensor

(

[

10.0

,

20.0

,

30.0

]

)

y

=

torch.

tensor

(

[

2.0

,

4.0

,

5.0

]

)

result

=

torch.

divide

(

x

,

y

)

print

(

result

)

 

tensor([5.0000, 5.0000, 6.0000])


PyTorch torch reference manual PyTorch torch reference manual