UserWarning: This overload of nonzero is deprecated: nonzero()

pytorch中的nonzero()函数

报错描述

UserWarning: This overload of nonzero is deprecated:
nonzero()
Consider using one of the following signatures instead:
nonzero(*, bool as_tuple) (Triggered internally at …\torch\csrc\utils\python_arg_parser.cpp:766.)
ids = (ovr <= threshold).nonzero().squeeze()

修改

报错描述中写得比较清楚,nonzero()函数需要加入bool as_tuple 参数。

原错误语句为:ids = (ovr <= threshold).nonzero().squeeze()
改为:ids = (ovr <= threshold).nonzero(as_tuple=False).squeeze()

欢迎关注【OAOA

你可能感兴趣的:(pyTorch深度学习框架)