记录算法工程中,模型相关报错可能得问题及解决方案。
Could not find variable deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_conv_op_k_5/bias.
1 2 3 4 5 6 |
E20221212 10:43:48.418906 5036 TFModelGrpc.cpp:27] CallBackScoreFunc() Request Failed, ModelName = online_model_4, Version = 5, status.error_code() = 9, status.error_message() = Could not find variable deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_conv_op_k_5/bias. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_conv_op_k_5/bias) [[{{function_node __inference__wrapped_model_36519}}{{node deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_conv_op_k_5/BiasAdd/ReadVariableOp}}]] E20221212 10:43:49.788563 5270 TFModelGrpc.cpp:27] CallBackScoreFunc() Request Failed, ModelName = online_model_4, Version = 5, status.error_code() = 9, status.error_message() = Could not find variable deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_dense_layer/bias. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_dense_layer/bias) [[{{function_node __inference__wrapped_model_36519}}{{node deep_fm_ranking_model/encoder_feature_layer_v2_1/user_play_online_seq_map_tag_dense_layer/BiasAdd/ReadVariableOp}}]] E20221212 10:43:49.925900 5226 TFModelGrpc.cpp:27] CallBackScoreFunc() Request Failed, ModelName = online_model_4, Version = 5, status.error_code() = 9, status.error_message() = Could not find variable deep_fm_ranking_model/encoder_feature_layer_v2_1/user_history_seq_map_label_7_dense_layer/bias. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/deep_fm_ranking_model/encoder_feature_layer_v2_1/user_history_seq_map_label_7_dense_layer/bias) [[{{function_node __inference__wrapped_model_36519}}{{node deep_fm_ranking_model/encoder_feature_layer_v2_1/user_history_seq_map_label_7_dense_layer/BiasAdd/ReadVariableOp}}]] |
对于tensorflow2 训练的模型可以采用如下做法修复(已验证):
https://stackoverflow.com/questions/62839498/keras-set-session-not-available-for-tensorflow-2-0
1 2 3 4 5 6 |
import tensorflow as tf from tensorflow.keras.models import load_model, Model from tensorflow.python.keras import backend as K sess = tf.compat.v1.Session() K.set_session(sess) |
对于TensorFlow1 训练的模型可以尝试采用如下做法修复(未验证):
https://blog.csdn.net/wwwangzai/article/details/102683059
1 2 3 4 5 6 7 8 9 10 |
global sess global graph sess = tf.Session() graph = tf.get_default_graph() # 在model加载前添加set_session set_session(sess) #加载模型 with graph.as_default(): set_session(sess) |
【TensorFlow】模型导出线上报错相关问题