似乎我只能将警告模块设置为全部或无,我正在尝试确定原因
在我的脚本顶部,我使用了
warnings.simplefilter(action='once')
或
warnings.simplefilter(action='ignore')
当我将操作设置为ignore
时,它会按预期隐藏所有警告。但是,当我将操作设置为once
时,它会在每次调用我的函数时打印警告(在循环中,从脚本中的另一个函数)。例:
/home/ec2-user/predict_evaluate/gt_ops.py:203: UserWarning: Too many positive examples of class {label} to balance dataset! Try increasing predict limit. warnings.warn(msg) /home/ec2-user/predict_evaluate/gt_ops.py:203: UserWarning: Too many positive examples of class {label} to balance dataset! Try increasing predict limit. warnings.warn(msg) /home/ec2-user/predict_evaluate/gt_ops.py:203: UserWarning: Too many positive examples of class {label} to balance dataset! Try increasing predict limit. warnings.warn(msg)
阻止action=once
工作的原因是什么
目前没有回答
相关问题 更多 >
编程相关推荐