ok, Can search this article probably encountered the problem that I have already encountered . Today pytorch Upgrade to 1.6.0, Find out tensor and int The division between cannot be used directly '/'. Mingming 1.5.0 It can be used -_-. The compatibility of the torch is worth make complaints about .
Look directly at this problem Official documents That's all right. ：
perhaps , Look at my solution ：
about tensor A And integer n Division between ：
result = A / n # not supported in torch 1.6.0 # solution result = torch.floor_divide(A, n)
This floor_divide amount to python Medium '//', namely The result is an integer ( Take out the number after the decimal point ).
If you don't want this division , Want to get an exact number with a decimal point , You can ：
result = torch.true_divide(A, n)
Select the above two division methods according to the specific situation , To solve this problem issue.