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

2024-04-25 16:44:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个用TF1创建的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().

我想最好修复这个警告,或者干脆压制它!在

到目前为止,我已经尝试过:

^{pr2}$

编辑:这个模型来自tensorflow hub,所以我还没有建立它。在


Tags: to警告forobjectistftensorflowcreate
1条回答
网友
1楼 · 发布于 2024-04-25 16:44:32

TensorFlow的登录在最近的版本中发生了变化,TF_CPP_MIN_LOG_LEVEL不再使用(参见问题#26348和{a2})。{cd2>尝试}。在

import tensorflow as tf
tf.get_logger().warning('test')
# WARNING:tensorflow:test
tf.get_logger().setLevel('ERROR')
tf.get_logger().warning('test')
# (silence)

相关问题 更多 >