簡體   English   中英

將 tensorflow 1.xx model 裝入 tensorflow 2.xx

[英]Loading tensorflow 1.x.x model into tensorflow 2.x.x

我有一個用 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

編輯:這個 model 來自 tensorflow 集線器,因此我沒有構建它。

登錄 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM