我有一个使用 TF1 创建的 SavedModel
正在加载 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().
我想优先修复这个警告,或者只是抑制它!
到目前为止我已经尝试过:
# In my python app
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# In my Dockerfile
ENV TF_CPP_MIN_LOG_LEVEL 2
编辑:这个模型来自 tensorflow hub,因此我没有构建它。
最佳答案
TensorFlow 中的登录在较新的版本中发生了变化,TF_CPP_MIN_LOG_LEVEL
不再使用(参见问题 #26348 和 #31870)。尝试使用 tf.get_logger().setLevel('ERROR')
。
import tensorflow as tf
tf.get_logger().warning('test')
# WARNING:tensorflow:test
tf.get_logger().setLevel('ERROR')
tf.get_logger().warning('test')
# (silence)
关于python - 将 tensorflow 1.x.x 模型加载到 tensorflow 2.x.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58626275/