Python 将tensorflow 1.x.x模型加载到tensorflow 2.x.x中

Python 将tensorflow 1.x.x模型加载到tensorflow 2.x.x中,python,tensorflow,Python,Tensorflow,我创建了一个SavedModel,其中TF1与TF2一起加载 图中的每个变量似乎都有一个警告,即: WARNING:tensorflow:Unable to create a python object for variable <tf.Variable 'Encoder_en/hidden_layers/tanh_layer_0/bias:0' shape=(512,) dtype=float32_ref> because it is a reference variable. I

我创建了一个
SavedModel
,其中TF1与TF2一起加载

图中的每个变量似乎都有一个警告,即:

WARNING:tensorflow:Unable to create a python object for variable <tf.Variable 'Encoder_en/hidden_layers/tanh_layer_0/bias:0' shape=(512,) dtype=float32_ref> because it is a reference variable. It may not be visible to training APIs. If this is a problem, consider rebuilding the SavedModel after running tf.compat.v1.enable_resource_variables().

编辑:此模型来自tensorflow hub,因此我没有构建它。

在tensorflow中的登录在较新版本中发生了更改,并且不再使用
TF\u CPP\u MIN\u LOG\u LEVEL
(请参阅问题和解决方案)。尝试使用
tf.get_logger().setLevel('ERROR')

# In my python app
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

# In my Dockerfile
ENV TF_CPP_MIN_LOG_LEVEL 2
import tensorflow as tf
tf.get_logger().warning('test')
# WARNING:tensorflow:test
tf.get_logger().setLevel('ERROR')
tf.get_logger().warning('test')
# (silence)