如何关闭tensorflow contrib模块警告

How to turn off tensorflow contrib module warning

我仍在使用 tensorflow 1.15,不会在当前项目中使用 tensorflow 2.0。

我想知道如何关闭此警告消息:

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

我已经阅读了提到的页面,但仍然不知道如何关闭该消息。

经过仔细搜索,我在 https://github.com/tensorflow/tensorflow/issues/27045#issuecomment-480691244

中找到了答案
import tensorflow as tf
if type(tf.contrib) != type(tf): tf.contrib._warning = None