如何抑制“未来警告”张量流?

Pra*_*eek 3 python terminal ubuntu numpy tensorflow

我正在 ubuntu 终端上运行使用 TensorFlow 的“./buildTF.sh”。并得到错误为:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516:
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated;
in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
Run Code Online (Sandbox Code Playgroud)

小智 7

这是由于 numpy 版本而出现的警告消息,请卸载当前的 numpy 版本并将其更新为1.16.4.

# pip uninstall numpy 
# pip install numpy==1.16.4
Run Code Online (Sandbox Code Playgroud)

感谢ymodak


Y0d*_*0da 5

这些警告是经典的FutureWarning,这意味着您可以使用warningspython 标准库中的模块使它们静音:

import warnings
warnings.filterwarnings("ignore", message=r"Passing", category=FutureWarning)
Run Code Online (Sandbox Code Playgroud)

这将检查FutureWarning并静音包含r"Passing".