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:

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



  • 相关阅读:
    kill一个pthread_test.bin测试程序主线程、子线程退出kernel flow
    signal bit operation
    pthread
    信号发送处理流程
    sdcardfs
    node小贴士03
    node小贴士02
    node小贴士01
    siteserver cms 搜索功能
    语法的高亮显示
  • 原文地址:https://www.cnblogs.com/luo-c/p/14320991.html
Copyright © 2011-2022 走看看