zoukankan      html  css  js  c++  java
  • 关于Pytorch报警告:Warning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead

    在使用Pytorch的时候,遇到警告的日志打印:

    [W IndexingUtils.h:20] Warning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead. (function expandTensors)
    [W ..atensrcATen ativecudaLegacyDefinitions.cpp:55] Warning: masked_scatter_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead. (func
    tion masked_scatter__cuda)

    虽然不影响使用,但是由于满屏的警告,使得覆盖了重要的输出信息。

    解决办法:

    在StackOverflow上,看到有回答:

     在自己的代码中,找到 mask 将其 .byte( ) 改为 .bool( ) 即可。

    mask = autograd.Variable(torch.zeros((a, b))).byte()  

    改为:

    mask = autograd.Variable(torch.zeros((a, b))).bool()  

    一般问题都是出现在对 loss的自动求导上。

    修改完后,发现训练速度都快很多:

    Before:

     After:

    可以看到,因为不需要每一步都打印警告日志,训练速度比之前快很多。



  • 相关阅读:
    利用NABCD模型进行竞争性需求分析
    团队组建及项目启动
    结对项目
    归档二
    归档(1)
    自定义cell
    CoreData(数据持久化的方式)
    autoLayout(相对布局)二
    autoLayout (相对布局)1()
    细节知识点的记忆
  • 原文地址:https://www.cnblogs.com/luo-c/p/14320991.html
Copyright © 2011-2022 走看看