RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel

简介: RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel

项目场景:


提示:新版python在pytorch中张量与原始数据的除法计算问题。


问题描述


报错


RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.


出错代码:(100 * correct / total)


其中correct为张量,total为常量。


解决方案:


(100 * torch.true_divide(correct,total)) 
# 使用pytorch模型提供的处理函数实现即可。 
# /符号,精确除法,替代函数: 
torch.true_divide(a,b) 
# //符号,整除,替代函数:
torch.floor_divide(a,b)


目录
相关文章
|
30天前
|
JavaScript 程序员 Swift
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
23 0
|
10月前
|
JSON 数据格式
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
240 0
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
371 0
解决RuntimeError: running_mean should contain 36864 elements not 4096
一般在卷积层Conv2d后添加正则化BNBatchNormal,使得数据在relu激活前不会因为数据过大而导致网络不稳定,而我在代码中BatchNorm2d的输入通道数与前一层Conv2d的输出通道数不一致,导致报这个错,两者修改一直即可(这里修改为36864即可)。
959 0
|
关系型数据库 MySQL 数据库
当你遇到Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value:
当你遇到Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value:
2015-03-18 - Deliberately pass a wrong note type for my task creation
2015-03-18 - Deliberately pass a wrong note type for my task creation
78 0
2015-03-18 - Deliberately pass a wrong note type for my task creation
2015-03-17 current note creation logic in my task
2015-03-17 current note creation logic in my task
92 0
2015-03-17 current note creation logic in my task
why process type for MyOpportunity creation is empty
why process type for MyOpportunity creation is empty
83 0
why process type for MyOpportunity creation is empty
My task - how is inline creation implemented
Created by Wang, Jerry, last modified on Mar 07, 2016
My task - how is inline creation implemented